Features of product variant Search

HCL Commerce Search is aware of variants and can process, retrieve and display them in the storefront. A number of features and usage scenarios are available.

You can find new search features specific to variants in the following areas:

Search index

  • There are new temporary tables for use with variants. They are:
    • TI_GROUPING_VARIANT_#INDEX_SCOPE_TAG#
    • TI_DPVARIANT_#INDEX_SCOPE_TAG#

    For more information, refer to the Temporary table schema definition.

  • A new index field, parentVariant_id, has been added to associate VariantBean with ItemBean. The value of the field can be used in queries to retrieve matching documents, and it can be retrieved by queries.

Publish and Unpublish

Child variants and SKUs are unpublished when a product is unpublished. Child SKUs are unpublished when a variant is unpublished. Otherwise, each variant and SKU will keep its own publish or unpublish value.

Price

  • If the price is indexed from the standard offer price, the variant index price will inherit from its parent product if the variant itself does not have a price defined.

Search Type

  • Four search types have been created so that the store can show all Variants in browsing results and search results. The search types are 20000, 20001, 20002 and 20003.
  • Variants are excluded for the existing search types: 0, 1, 2, 3, 100, 101, 102, 103, 1000, 1001, 1002, 1003, 10000, 10001, 10002, 10003.
  • Variants are included for the existing search type: 10, 11, 12, 13.

    For more information, see Changing the default search type.

Search REST API

Combine search rest APIs with search type to show variants
REST APIs whose search profile contains provider com.ibm.commerce.search.internal.expression.provider.SearchTypeExpressionProvider can specify the appropriate search type to return a variant.
For example:
  1. Complete Scenario 1: Set the default search type to include variants.
  2. Access the search rest APIs to display variants. For example, access API store/{storeId}/productview/byCategory/{categoryId} to get the variants details list under the specified category. Access API store/{storeId}/productview/bySearchTerm/{searchTerm} to get the matched variants details list. Following is a response sample:
    {
     “recordSetCount”: 2,
    	...
    	"catalogEntryView": [{
    		"hasSingleSKU": false,
    		"resourceId": "http://localhost:3737/search/resources/store/1/productview/byId/17001",
    		"uniqueID": "17001",
    		"partNumber": "10001-Red-variant",
    		"catalogEntryTypeCode": "VariantBean",
    		"buyable": "true",
    		"storeID": "10501",
    		"parentCatalogGroupID": ["10001_10001", "10502_10001"],
    		"price": [...],
    		"attributes": [...]
    	}, {
    		"hasSingleSKU": false,
    		"resourceId": "http://localhost:3737/search/resources/store/1/productview/byId/17002",
    		"uniqueID": "17002",
    		"partNumber": "10001-Teal-variant",
    		"catalogEntryTypeCode": "VariantBean",
    		"buyable": "true",
    		"storeID": "10501",
    		"parentCatalogGroupID": ["10001_10001", "10502_10001"],
    		"price": [...],
    		"attributes": [...]
    	}],
    	...
    }
    
Use API /{storeId}/productview/byId/{productId} to get product details
  • Add the field numberOfVariants to display the number of child variants.
  • Add object variants to display the child variant details list.
    Note: By default, variants and numberOfVariants are not available. For information on how to view them, see Scenario 2: View child variants of a product.
    Here is a response example:
    {
    	...
    	"catalogEntryView": [{
    		…
    		"uniqueID": "10001",
    "catalogEntryTypeCode": "ProductBean",
    		…
    		"numberOfSKUs": 13,
    		"sKUs": […],
    		"numberOfVariants": 2,
    		"variants": [{
    			"hasSingleSKU": false,
    			"resourceId": "http://localhost:3737/search/resources/store/1/productview/byId/17001",
    			"uniqueID": "17001",
    			"partNumber": "10001-Red-variant",
    			"ad_attribute": "7000000000000000002/_/swatchcolor/_/Color/_/.00000/_/7000000000000000007/_/Red/_/Red/_/1.00000/_/1/_/1/_/1/_/0/_/1/_/1/_/images/catalog/apparel/women/Swatches/swatch_red.png/_/-/_/one/_/C62/_/0",
    			"catalogEntryTypeCode": "VariantBean",
    			"buyable": "true",
    			"storeID": "10501",
    			"parentCatalogGroupID": ["10001_10001", "10502_10001"],
    			"price": [...]
    		}, {
    			"hasSingleSKU": false,
    			"resourceId": "http://localhost:3737/search/resources/store/1/productview/byId/17002",
    			"uniqueID": "17002",
    			"partNumber": "10001-Teal-variant",
    			"ad_attribute": "7000000000000000002/_/swatchcolor/_/Color/_/.00000/_/7000000000000000008/_/Teal/_/Teal/_/2.00000/_/1/_/1/_/1/_/0/_/1/_/1/_/images/catalog/apparel/women/Swatches/swatch_teal.png/_/-/_/one/_/C62/_/0",
    			"catalogEntryTypeCode": "VariantBean",
    			"buyable": "true",
    			"storeID": "10501",
    			"parentCatalogGroupID": ["10001_10001", "10502_10001"],
    			"price": [...]
    		}],
    	...
    }
    
Use API /{storeId}/productview/byId/{variantId} to get variant details
  1. The API response contains basic variant information such as child SKUs and attributes.
  2. The attributes object contains the specified variant’s attributes, and its child SKUs’ defining attributes.
  3. Add the field bindToVariant. If an attribute contains this field and the value is true, then this attribute is the defining attribute associated with the variant.
    Following is an example of a variant that associates with the defining attribute red. It contains two child SKUs, and the child SKUs’s defining attribute swatchSize(XS,M) is accumulated to the variant:
    {
    	…
    	"catalogEntryView": [{
    		"hasSingleSKU": false,
    		"resourceId": "http://localhost:3737/search/resources/store/1/productview/byId/17001",
    		"uniqueID": "17001",
    		"subscriptionTypeCode": "NONE",
    		"partNumber": "10001-Red-variant",
    		"catalogEntryTypeCode": "VariantBean",
    		"parentCatalogEntryID": "10001",
    		"buyable": "true",
    		"storeID": "10501",
    		"parentCatalogGroupID": ["10001_10001", "10502_10001"],
    		"disallowRecurringOrder": "0",
    		"price": [],
    		"numberOfSKUs": 2,
    		"sKUs": [...],
    		"attributes": [{
    			"identifier": "swatchcolor",
    			"values": [{
    				"identifier": "Red",
    				"sequence": "1.00000",
    				"unitOfMeasure": "one",
    				"unitID": "C62",
    				"image1": "images/catalog/apparel/women/Swatches/swatch_red.png",
    				"value": "Red",
    				"image1path": "/wcsstore/ExtendedSitesCatalogAssetStore/images/catalog/apparel/women/Swatches/swatch_red.png",
    				"uniqueID": "7000000000000000007"
    			}],
    			"usage": "Defining",
    			"displayable": true,
    			"bindToVariant": true,
    			"searchable": true,
    			"sequence": ".00000",
    			"storeDisplay": false,
    			"name": "Color",
    			"facetable": true,
    			"associatedKeyword": "-",
    			"comparable": true,
    			"uniqueID": "7000000000000000002"
    		}, {
    			"identifier": "swatchSize",
    			"sequence": "1.00000",
    			"storeDisplay": false,
    			"values": [{
    				"identifier": "XS",
    				"sequence": "1.00000",
    				"unitOfMeasure": "one",
    				"unitID": "C62",
    				"image1": "images/catalog/apparel/women/Swatches/swatch_size/size_xs_enabled.png",
    				"value": "XS",
    				"image1path": "/wcsstore/ExtendedSitesCatalogAssetStore/images/catalog/apparel/women/Swatches/swatch_size/size_xs_enabled.png",
    				"uniqueID": "7000000000000000004"
    			}, {
    				"identifier": "M",
    				"sequence": "3.00000",
    				"unitOfMeasure": "one",
    				"unitID": "C62",
    				"image1": "images/catalog/apparel/women/Swatches/swatch_size/size_m_enabled.png",
    				"value": "M",
    				"image1path": "/wcsstore/ExtendedSitesCatalogAssetStore/images/catalog/apparel/women/Swatches/swatch_size/size_m_enabled.png",
    				"uniqueID": "7000000000000000002"
    			}],
    			"usage": "Defining",
    			"displayable": true,
    			"name": "Available Sizes",
    			"facetable": true,
    			"comparable": true,
    			"searchable": true,
    			"uniqueID": "7000000000000000001"
    		}]
    	}],
    	…
    }
    
Use API /{storeId}/productview/byId/{sKUId} to get SKU details
Add the parentVariant_id field to associate an SKU with its parent variant.