cancel
Showing results for 
Search instead for 
Did you mean: 

How to group variants using Solr ?

Former Member
0 Kudos

Hi experts,

We customised Solr to index variants, the requirement is to group variants by the root product code (with "rootProductCodeValueProvider”) and display the main variant in first position.

For example I have Flash disk as base product and its variants are :

  • Flash disk White 16Go

  • Flash disk Gold 16Go

  • Flash disk Black 16Go

I need to display this group on the PLP regardless of the criteria used by Solr to sort products and display the "Flash disk White 16Go” in first position because it has mainVariantProduct = true

I added an attribute “baseProduct” to the Solr impex and the adequate provider “rootProductCodeValueProvider", this attribute will be used by Solr to group variants product. I used the HMC to add this group field name.

When I did that, I got just one search result when searching instead of all variants. Please could you help me to resolve this issue. Thank you.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

We have similar requirement of grouping variants and show default variant in listing and user can also see other variants in same row just click on the arrow. Any idea?

0 Kudos

Have you got any solution??

tylermac
Product and Topic Expert
Product and Topic Expert
0 Kudos

You're question is a little confusing because I think you're saying you want to see all 3 variants display, with the white one showing first? Are you saying you want them side by side or are you saying you want it grouped with "swatches" below the main image with the other options? If you want the first option when you group by baseProduct you're only going to see one result, and not the 3 variants. If you want to see the variants only you should either be a) indexing only the variants you want or b) grouping on whatever common value you want for the variants. It sounds to me like you don't want to group but then you need to add a sort criteria or boost rule where mainVariantProduct shows up first. If you attach a screenshot/wireframe of what a PLP is that you want to see it might be easier to figure out what the correct option is.

Former Member
0 Kudos

Hi Tyler McWilliam, Thank you for your response. In our case we need to get all variants for the same product model on PLP page (not just only the most relevant variant) and of course the main variant will be displayed in first position.

After investigation, grouping variants don’t solve this issue, because grouping allows us to group results by a predefined field (base product code) and only the most relevant documents per distinct field value of the predefined field will be kept in the search result.

So, the solution consists of adding some sort criteria … Thanks a lot

tylermac
Product and Topic Expert
Product and Topic Expert
0 Kudos

I think that sounds like the better option. You could also look at the hero products, but that would be a lot of manual work because you would have to manually order the variants. I agree your best option sounds to be modifying how items are sorted prior to display.