--- title: Index variants slug: o74c0543 canonical_url: https://docs.coveo.com/en/o74c0543/ collection: coveo-for-commerce source_format: adoc --- # Index variants 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](https://docs.coveo.com/en/ladf2011#step-8-create-the-index-types), you specify a [FlexibleSearch](https://help.sap.com/docs/SAP_COMMERCE/d0224eca81e249cb821f2cdf45a82ace/8bc399c186691014b8fce25e96614547.html) 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 ```sql 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: ```sql 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](https://docs.coveo.com/en/ladf2011#step-10-use-the-value-providers). ## Pros and cons The following table presents the pros and cons of the suggested approach. [%noheader, cols="^10%,45%"] |=== |🟢 a|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. |❌ a|Metadata is mixed in the SAP Commerce UI so it's impossible to tell which metadata is for which type (product vs variant). {nbsp} No way to separate products and variants in two different sources. {nbsp} No way to push and/or update products independently from variants and vice versa. |===