Developer forum

Forum » Development » option to show master product on product list if any variant contains facet selection

option to show master product on product list if any variant contains facet selection

Mikkel Hammer
Mikkel Hammer
Reply

Hi,
EDIT: i've attached the same pictures below aswell, since they show up quite big in the post.

We're looking for a way to show the master product on the product list if any variant contains the selected facet option.
As far as i know, it only takes the master product information into account.

Is it possible to get a feature into the query to take variant information into account,
or does anyone have experience with this, and can point us into the right direction for making it outselves?

For context:
We've extended the sticker functionality to check if the master product or any variant contains a specific value in a text product field, depending on which one it is - we show a "NEW PRODUCT" or "NEW VARIANT" sticker.

Our problem is that when it's only a variant that contains the value, it's not showing when you select the facet option.

Here is the product list without the facet with the specific value is selected. Now it shows the 3 master products with the correct stickers. (all 3 products image below)


Here is the product list WITH the facet with the specific value is selected. Now it shows the 2 master products where only the master product has the value. (only 2 products image below)


Best regards,
Mikkel Hammer

all_3_products.png only_2_products.png

Replies

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply
This post has been marked as an answer

Hi Mikkel,

 

We've done this to some customers, and you have the theory accurate. What you need is an index builder extender that will identify when the current document contains variants and then instantiate the variants and store the values you want directly in the master product.

At one point we tried to have a method that would do this for all variant data, but it not only increases the index build time far more than desirable, but it also gave us far too much information to deal with (i.e. listing the dropdown of field names to set the query, we'd have almost double the fields, because we had the normal field lists + the additional field with all variant data).

 

Ultimately you can only be listing master products so that your facets work correctly. So if you keep it simple to 1 or 2 fields, this is achievable with the IndexBuilderExtender. What I recommend for performance, is to get all variants from all products first and/or the first time you need it (go to the database once and then filter it per document), instead of instantiating (API or SQL) per document/product.

 

Depending on how many facets of this type you need, it can work just fine.

 

Best Regards,

Nuno Aguiar

Votes for this answer: 2
 
Mikkel Hammer
Mikkel Hammer
Reply

Hi Nuno,

Thanks for the detailed reply, and taking performance into account!
We'll look into making it with the IndexBuilderExtender as you mentioned :)

Best regards,
Mikkel Hammer

 

You must be logged in to post in the forum