Search usage scenarios for product variants
Some of the scenarios in which you can optimize HCL Commerce Search for product variants are described.
Scenario 1: Set the default search type to include variants
- Ensure that you have built variants into the index. For more information, see Using Search with product variants.
- Edit
WCDE_installdir\workspace\search-config-ext\src\runtime\config\com.ibm.commerce.search\wc-component.xml
to set the search Type to include variants. If the
wc-component.xml file does not exist, create one. For
example:
For more information about Search Types, see Changing the default search type.<?xml version="1.0" encoding="UTF-8"?> <_config:DevelopmentComponentConfiguration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.ibm.com/xmlns/prod/commerce/foundation/config ../xsd/wc-component.xsd " xmlns:_config="http://www.ibm.com/xmlns/prod/commerce/foundation/config"> <_config:valuemappingservice> </_config:valuemappingservice> <_config:extendedconfiguration> <_config:configgrouping name="SearchConfiguration"> <_config:property name="searchType" value="20000"/> </_config:configgrouping> </_config:extendedconfiguration> </_config:DevelopmentComponentConfiguration>
- Save your changes and close your file, then package and deploy your customization. See Packaging the customization.
- Restart the Search server.
Scenario 2: View child variants of a product
The REST API store/{storeId}/productview/byId/{productId}
only returns
child SKUs for a product by default. If you want it to return both child variants and
SKUs, follow the steps below.
- Ensure that you have built variants into the index, as described in Using Search with product variants.
- Redefine the
IBM_findProductByIds_Details
profile in the search configuration file (wc-search.xml). Set the search type to 20000, and replacecom.ibm.commerce.search.internal.expression.postprocessor.SearchCatalogEntryViewSKUQueryPostprocessor
with com.ibm.commerce.search.internal.expression.postprocessor.SearchCatalogEntryViewVariantAndSKUQueryPostprocessor
. For example:
Where:<_config:profile name="IBM_findProductByIds_Details" indexName="CatalogEntry"> <_config:query> <_config:param name="searchType" value="20000"/> <!-- Remove SearchCatalogEntryViewSKUQueryPostprocessor, and use SearchCatalogEntryViewVariantAndSKUQueryPostprocessor instead <_config:postprocessor classname="com.ibm.commerce.search.internal.expression.postprocessor.SearchCatalogEntryViewSKUQueryPostprocessor" /> --> <_config:postprocessor classname="com.ibm.commerce.search.internal.expression.postprocessor.SearchCatalogEntryViewVariantAndSKUQueryPostprocessor" /> </_config:query> </_config:profile>
- The default value of searchType is 1000. A searchType value of 20000 changes the search scope to include variants and exclude products.
- A searchType value can alternatively be set in the wc-component.xml file.
- Save your changes, and then restart the Search server.
- Access the REST API
store/{storeId}/productview/byId/{productId}
to view the child variants and SKUs of a product.