Indexing variants

This is for:

Developer

Indexing products and their variants from SAP Commerce Cloud into Coveo can enhance the search experience for your customers. While there are many ways to achieve this, the following general guidance outlines how to do so.

Index products and variants in the same index type

When you’re configuring the Index types for full indexing and incremental indexing, you specify a FlexibleSearch query to extract the data from SAP Commerce Cloud.

You can update a query to retrieve both products and their variants in the same query. This approach simplifies the indexing process and ensures that products and variants are indexed together.

For example, instead of

SELECT {p:pk}
FROM {Product AS p
  LEFT JOIN ArticleApprovalStatus AS a ON {p:approvalStatus} = {a:pk}
}
WHERE {a:code} = 'approved'

You can use a query like this to retrieve both the product and its ApparelSizeVariantProduct variant:

SELECT {p:pk}
FROM {Product AS p
      LEFT JOIN ArticleApprovalStatus AS a ON {p:approvalStatus} = {a:pk}
      LEFT JOIN ApparelSizeVariantProduct AS v ON {p:pk} = {v:baseProduct}}
WHERE {a:code} = 'approved'

By using this query, on the Fields tab, you’ll see the fields populated for both the product and the variant.

Tip

For some products and variants, you may have to use the value providers to populate the fields with correct values.

You can use value providers to apply custom logic to data. For example, when you need to form a price dictionary field that contains a JSON object with different prices.

For more information, see Use the value providers.

Pros and cons

The following table presents the pros and cons of the suggested approach.

🟢

Products and variants are:

  • on the same index type and will be indexed by one cronjob.

  • on the same source and can be filtered by objectType metadata.

  • pushed in a transactional way.

Metadata is mixed in the SAP Commerce UI so it’s impossible to tell which metadata is for which type (product vs variant).

 

No way to separate products and variants in two different sources.

 

No way to push and/or update products independently from variants and vice versa.