Developer forum

Forum » Ecommerce - Standard features » ProductList for Master/variant products, with facets on variant properties

ProductList for Master/variant products, with facets on variant properties

Hans Kloppenborg
Reply

Hello,

We are trying to create a productlist page using the ProductListViewModel for our product catalog with master products who can have a lot of variants (for example a type of screw with lots of length and diameter variants), and where the variants have category fields with their properties.

We want to show and page for a fixed amount of master products, with 5 variants visible and a toggle to show all, and be able to filter them with facets on the variant properties. As far as we can see we need to output the variants in our product query if we want to filter them using facets, but if we output the variants the paging becomes very weird. For example, say we set the pagesize on 50, the first page for some products would only contain one masterproduct if it has 50 variants, and if it has more as 50 some variants would only show on the next page.

We where thinking of making a custom paging ourselves, but that would mean that we would need to set the pagesize on 10000 or something, and every call to the productlist page would become propably very slow.

As far as we could see the notifications happen after the query has selected its top x of results, so there is no possibility to extend the query to search the variants but only output the master products.

Is there any way how we could influence the query that gets executed by the ProductListViewModel? (We could really use that since we also need to filter what products are shown depending on the customer, although we might be able to use assortments for that, if that works in combination with productlists/paging)

If anyone has experience with the display of master/variant combinations and paging please let us know how to solve this.

Greets Hans


Replies

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

Hi Hans,

 

We come across this every now and again. To ensure I understood your struggle, let me say it back in other words:

  • You want to search all products in your query (regardelss if they are variants or master products"
  • Then you want to return
    • If a master - return the master
    • If a variant record - return the master of that variant
      Don't return "duplicate masters"

 

If that's accurate, what we did to overcome this was to create an IndexBuilderExtender that created new properties with a bundled info of the children/variants. That way you only search for masters and return masters.

 

However this is not painless, because of facets. This means that the facet option count is skewed. For example:

  • A t-shirt is sold in 3 sizes and 3 colors
  • That means 13 records - 12 variants + 1 master
  • If you're only listing masters, then your facet option counts will always be 1 (the master), regardless you having 3 "Red" t-shirts
  • And the Facet options will always have all 3 colors and sizes, because they all belong to the same master product

 

For this particular example it might be fine, but you may have other products where it might be an issue.

 

 

So, unless the facet options can be rendered based on the QueryResult, but then the list of results can be filtered to return only master products, you'll still have an issue.

 

Best Regards,

Nuno Aguiar

Votes for this answer: 1
 
Hans Kloppenborg
Reply

Hi Nuno,

Thanks for your feedback how you solved it in your case, we have meanwhile solved it by changing the query to return/search only the variants, setting te pagesize on 9999, and then in the backend create an extended model where we group the variants by Id, get the masters for those ids and return the masters with their variants. Also we created a custom paging mechanism using the masters we found. (we have pages with a fixed amount of masters)

We just got this working and our facet numbers are correct too :) 

Only minor issue we see is that performance is less than optimal, since all variants of the selected categorie are fetched every time, though at this moment it seems ok.

Greets Hans

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Hans,

 

Thanks for sharing that too. I would imagine performance would be the issue with that approach (unfortunately).

 

Nuno Aguiar

 

You must be logged in to post in the forum