Developer forum

Forum » Ecommerce - Standard features » Show only colors in product list (and keep filter possibilities)

Show only colors in product list (and keep filter possibilities)

Martin Moen
Reply

Swift: 1.22.0
Dynamicweb: 9.16.2

So we have these lovely products:

  • PROD1 - Pants Blue XS
  • PROD2 - Pants Blue XL
  • PROD3 - Pants Red XS
  • PROD4 - Pants Red L
  • PROD5 - Pants Yellow M

Since they are variants, we have created variant groups and options:

  • Colors
    • VO1 - Blue
    • VO2 - Red
    • VO3 - Yellow
  • Sizes
    • VO4 - XS
    • VO5 - M
    • VO6 - L
    • VO7 - XL

Further on we have combined the products into a model:

  • PROD1 - Pants
    • PROD1 - Pants Blue XS - VO1 - VO4
    • PROD2 - Pants Blue XL - VO1 - VO7
    • PROD3 - Pants Red XS - VO2 - VO4
    • PROD4 - Pants Red L - VO2 - VO6
    • PROD5 - Pants Yellow M - VO3 - VO5

So far so good. Now we would really like to show only the colors in the product list. So expected result should be three items in the product list:

  • Pants Blue
  • Pants Red
  • Pants Yellow

By changing the query I know we can do something like this:

  • Is variant = True
  • Color - First variant in group = True

The problem with this approach is that it first of all excludes all products that does not have variants, and it also excludes those who dont have colors, but only have size. Another big problem is that filters for size are not longer working. We can filter for colors, but when trying to filter by size, only the first sizes in each color is available. Not the entire range of sizes.

So the question is, how do you go proceed if you would like to:

  1. Only show color variants in the product list
  2. Be able to filter for the full range of sizes
  3. Not exclude non-variant products, and products with different variant groups

Replies

 
Martin Moen
Reply
 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Hi Martin

Have a look at the field in the index called "Include Master/Variant in list" together with "Show in list"

  • If the product is a master and has no extended variants, it will show up in lists
  • If the product is a master and there is no extended variants marked to be shown in product lists, we show the master product anyways

Also you can have a look at "Extended variant count/ExtendedVariantCount" - if it is 0 it is a master so it can be combined with first variant in group.

You also have primary variant if the master has been setup to have a default variant.

 

 
Martin Moen
Reply

Still does not work together with filters. The example below is not using the properties you mentioned, but the result is the same.

If we use IsVariant = False then only the model show up in the list, but then again it is possible to filter on all colors and sizes (we want this).

But also, we would like to display all the colors in the list. Like this.

Here we have IsVariant = True and Colors - First variant in group = True. But as you can see, now the size filters only show the options matching the ones in the list. We still would like to filter all the available sizes.

A solution we are thinking about is to only combine the variants on size and not color and size all together. Like that we get a model representing each color. But then again we dont get the relation between each color model...

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Well - it comes down to how these things work and what data is in the index.

 

Thinking out loud with no exact point :-):

For a master with variants, the color field would have values for all colors that exist as variants. You would get 1 option for each color that the product exist in, because there is one document matching each color - and that match would be the master it self. Also all the sizes that the master comes in, will result in the size facet with one option for each size pointing to the master.

If you switch to using variants instead of masters, you will only get the sizes that are part of the list - and since the master is not on the list, you will not get anything from that record, but only the size related to the first of each color.

So if you have more than 2 variant groups, it becomes difficult with what we have now.

Say you have 2 colors, in 2 sizes and a master - that would be a total of 5 products/lucene documents. In your first scenario your result would be the master and using the variant options from that, and in your second scenario that would be 2 of the 4 records (one for each color, leaving out 2 sizes) - and that would give you facet option issues for the size (as 2 documents are missing).

So what you need is a solution that would index 3 documents - the master and one for each color, leaving all the sizes of each color as options on those colors....

That requires 'half variants' or 'variant masters' in the index, and I do not know how to solve that....

Could it be a column on the index that is indicating if a product is either

  • A master with no variants
  • The first variant in the first variant group

And then a field that only exist for documents that has "{Color} - First variant in group" set to true, that is "{Size} - Other variant options for primary variant group".

Or got any other ideas?

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Martin and Nicolai,

 

What we did in the past was to:

  • Using an IndexBuilderExtender, extend (only) the master record to contain data from the variant that is relevant
    i.e. Colors and Sizes and even some other variant specific field values, so that it would just be discoverable
  • That would only return master products, but allowed us to find products that would contain the relevant data
    (this was also needed for free text search)
  • In the template you may need to customize the Components (considering it's a Swift site) to then only render the desired variant combinations and/or variant options

 

Hope this helps,

Nuno Aguiar

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Hi Nuno

Would that not give issues? - the amount of products returned has to fit exactly with the search result. Modifying what is being rendered would mess up the paging and facets running on other attributes.

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Nicolai,

 

We don't expose the number of results per facet in those scenarios, because of that reason. Basically we're displaying the "t-shirts" or the "shoes" that can be purchased in "Red".

 

This means we just work with master records, so everything just works as expected.

 

 

You must be logged in to post in the forum