Group base products by relationship (elasticsearch)

Hi,

Our client has products with different colors and sizes. Each color is a base product, and that base product has the sizes for that specific color. Each color is then linked to the other colors of the same product via a relationship. We use the display template “ProductWithVariantList”.

We want to group each base product that has a relationship. By default, this is not possible from what we’ve seen. We also tried to modify the ProductIndexDocumentBuilder, but we’re not sure how or if it’s possible to do it.

Our client does not want to have a variant for each color and size combination, but we know that that would be a possible solution.

Litium version: 7.7.1

1 Like

Bump bump…! :slight_smile: :slight_smile:

What are the expectations of the grouping? Does it matter which base product is shown?

One idea could be that you have a flag on the base product if it should be hidden from search and hide all base products but 1.

Another idea could be that when indexing you fetch the other related products and queue a deletion of them from the index, so in the end only a single base product is left. In this scenario, it would be different base products depending on which was indexed last.

For filters to work, you would in either case have to add the other base products data to the single base product.

Here is an example from a web store, where they have two colors of the same product, and you can change color on the product card in the category listing:

This is basically what we want to achieve aswell. Note that the pictures are the same product card, where I picked another color, not two separate cards.

We still need the base products in the index, as they should still be available as a product page.

How would I add the other base products’ data to a single base product?

I don’t really see how there’s fewer variants in this scenario than if you were to have a single base product with all colors and sizes, a data model that would make achieving this design easier. Is it necessary to keep them as separate products?

The index is not really set up to merge base products together. You could combine the data in PopulateProductDocument by getting the related base products and adding their data to the single index document.

Deleting the index document only stops it from showing up in listings, it wouldn’t affect the product page.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.