Search icon

Grouping Product Variants

Grouping product variants in the data feed that share the same basic set of attributes can help you improve your search results.

Say you have these two hoodies in your feed:

  • Nike Sportswear Phoenix Hoodie (size: S; color: baby pink)

  • Nike Sportswear Phoenix Hoodie (size: M-L; color: mint green)

These are two different products, and when looking for "hoodie", the two would show up in the search results:

Grouping products variants

However, you may prefer the user to obtain just one "Nike Sportswear Phoenix Hoodie " search results with all variants of colours and sizes available in the filters of your search results.

This way, when the user looks for a "Phoenix Hoodie", only one result is shown, but all colors and sizes are available at the filters panel.

Grouping variants example

Group Variants As a Single Item

Using Doofinder, you can set this up in the following simple steps:

  1. Go to Configuration > Search Engines > click on "See indices" > on Indices > scroll down to the Configuration section > Enable Group variants as a single item option, then click "Save".
    Grouping variants as a single item
  2. Ensure the products you want to be grouped share the same group_id field in your data feed.

Using the Item group_id

Alternatively, you may use the default standard by Google from the data feed: the item group id. Through this, all items with the same group_id attribute are considered variants of the same item.

Consequently, when you check the group products by group_id, all products that share the same group_id attribute are displayed as one product only in the search results. Still, all their variants, like colour or size, if defined as filters, are displayed in the filters.

Note that updating the group_id of an item will affect the grouping.

If you are indexing through API, make sure the value for group_id is a string.

Marking an Item As Group Leader

Follow the Leader

If there's an item with the field group_leader set to "true", that item will be chosen as the group representative in search results (if there are no other relevant sort criteria involved). All other items in the group must have the group_leader field set to "false". This way, the leader will be differentiated from the rest.

If you are using the API, you need to set a boolean value for group_leader. Currently, we accept a pure boolean or string, example: true, false, "true", "false".

Lastly, the field name could be in two formats:

  • Text Format

    Grouping items: For product type feeds, you can use the group ID, group_id. This will work for every data type (not just the product data type).

    Marking an item as the group leader: You use the group_leader field.

  • XML Format

    Grouping items: For product type feeds. You can use group_id. This will work for every data type (not just the product data type).

    Marking an item as the group leader: You need to use group_leader.

Adding Variant Information to the Data Feed

If you use a custom data feed, you can tell Doofinder which attributes differentiate the variants of a group, such as color or size. Doofinder uses this information to display a variant selector in the Add to Cart button, so your customers can choose the exact variant from the layer. It is also used by the variant options and swatches of the Fashion theme.

Follow these steps:

  1. Group the variants with the group_id field and mark the parent product with group_leader set to true, as explained above.
  2. In the group leader, add the df_variants_information field. Its value lists the attributes that differentiate the variants, separated by %%.
  3. In each variant, add those attributes with their own value.

For example, if your variants differ by color and size, the group leader includes:

  • TXT file:
header: df_variants_information
value: color%%size
  • XML file:
<df_variants_information><![CDATA[color%%size]]></df_variants_information>

Each variant then includes the color and size attributes. For example, for the color:

  • TXT file:
header: color
value: Black
  • XML file:
<color><![CDATA[Black]]></color>

Example of how the group leader should be configured in your feed:

"id": "51227",
"group_id": "2546",
"group_leader": true,
"df_variants_information": "color%%size"

Example of two variants of the same group:

"id": "51228",
"group_id": "2546",
"group_leader": false,
"color": "Black",
"size": "M"
"id": "51229",
"group_id": "2546",
"group_leader": false,
"color": "White",
"size": "L"

To enable the variant selector in the Add to Cart button and configure the display order of the variant values, see the Add to Cart documentation.

If implementing with one of our plugins, then the behavior will be:

We index both the parent and child products
(group leader and variant, respectively).

  • If products are grouped, the parent product acts as the leader and is displayed in the results.
  • However, if a specific SKU of a child product is searched for, we return the child product instead, since it was explicitly requested.

You can use the Excluded Results rule to hide the variants, that way your customers will only be able to find the product parent. However, there is no option to change the variant links from our side.

If you prefer to use always one single product, you will need to provide your own product data feed, and there will be no need to index variants.

Sorting Product Variants by best_price

Using the Relevance Criteria functionality allows you to dictate whether the smallest best_price should be the leader product to show on the layer.

When the products are grouped as one and the group_leader is “true” in the data feed, the price shown will be the price of the group_leader. If you need to change that order to be “lowest” to “highest” you can do it by configuring the best_price under the Search > Advanced Preferences > Relevance Criteria:

Follow the Leader

With that configuration, the price shown first will be the lowest value.

Variants Out Of Stock

You have the possibility to hide all “out of stock” products at once, see here! However, you might want to show the “out of stock” products down below on the search instead of hiding it.

Notice that, when the items are grouped together, and all variants are “out of stock”, the product will disappear entirely if you’re hiding the “out of stock” products.

When not all products are “out of stock”, using the Relevance Criteria over Availability will make sure you control which product comes first, ensuring always the display of the “in stock” products as an example.

If you have sorted the best_price to be lowest first (see Sorting Product Variants by best_price above), then, when sorting by availability, the first product shown will be the first available and the cheapest. Your relevance Criteria configuration should look like that:

Follow the Leader

This configuration is very sensitive, do not remove the Score and revert the changes if you notice any discrepancies on your search.

Last updated: 22/09/2026

Did you find this page helpful?