Loading...
Area: Episerver Commerce
Applies to versions: 10 and higher
Other versions:

Indexing variants in a product document

This topic explains how to index a variant for a product document in a solution using the Episerver Find-Commerce integration (EPiServer.Find.Commerce). The topic also provides examples of including and excluding variants, and adding price and inventories to a product document to be indexed. 

Indexing the entire variant inside the product

By default, variants are indexed as ContentReferences inside the product document sent to the Find index. This allows all variant references for a specific product from the index and gets the product for a specific variant.

Depending on how your site works, it might be better to index the entire variant inside of the product, as shown in the following examples.

Overriding CatalogContentClientConventions

Override the CatalogContentClientConventions class, and register it in an initialization module to override the default conventions.

Excluding variant reference indexing for product content

To exclude variant references, override the ApplyProductContentConventions, and exclude the field using conventions.

Including related variant content items in product content

Create a new extension method for product content to be able to index variants for it.

Adding default price and prices in product content

The following example shows how to

  • index the highest default price for product variants
  • index prices from variants in the Prices extension method

Adding inventory in product content

The following example shows how to index the inventories from variants.

Excluding indexing of variant content

Exclude the variant content from being indexed by calling ShouldIndex for the type, using the conventions API.

Listening for price and inventory changes

The CatalogContentEventListener class listens for price changes for classes that implement IPricing, and inventories for classes that implement IStockPlacement. VariationContent implements both of them, but ProductContent does not implement them. Therefore, override the default implementation and make some changes.

Last updated: Oct 24, 2016