Developer forum

Forum » Ecommerce - Standard features » Indexed query and Master/Variant list with facets

Indexed query and Master/Variant list with facets

Kenneth Radoor
Reply

We have a solution where we have products with variants, thise products have some productsfields made up of lists.

The values will vary on the variants

We want to be able to filter on thise values, but in the productlist only show the Master product.

If we in the query set the value of "Include Master/Variant in list" to true, we only get the "master" product, as we want.

But the filter do not reflect the posible values of all the productfield values set on the variants. We only get the values that are set on the Master product, and not all posible values for master AND variants.

This functionality was posible with the old product filters in DW 8.

Is there a way to make the same with Repositories ?

The solution is http://powertechnic.dw9.dynamicweb-cms.com/produkter/led-drivere 


Replies

 
Nicolai Pedersen
Reply
This post has been marked as an answer

Hi Kenneth

You can only accomplish this by making a IndexBuilderExtender that will take the values from the variants and add them as a field on the master:

class IndexBuilderExtenderExample : IndexBuilderExtenderBase<ProductIndexBuilder>
{
public override void ExtendDocument(IndexDocument document)
{
if (document.ContainsKey("ID"))
{
string productid = (string)document["ID"];
}
if (document.ContainsKey("ProductNumber"))
{
string productNumber = (string)document["ProductNumber"];
document.Add("ProductNumberCleaned", productNumber.Replace(".", string.Empty));
}
document.Add("CustomField", DateTime.Now);
}
}
Votes for this answer: 1

 

You must be logged in to post in the forum