Developer forum

Forum » CMS - Standard features » Range price facets

Range price facets

Thomas Larsen
Reply

Is there a best practice or some example code on how to implement range price facets, on the new repository index?

 

On a product list I want to create the following filter

 

Price

---------------------------------
[  ] 0 - 999 DKK (5)

[  ] 999  -  1999 DKK (4)

[  ] 2000 - 2999 DKK (2)


Replies

 
Nicolai Pedersen
Reply
This post has been marked as an answer

Hi Thomas

It seems to be missing. But here goes.

  1. First create a new field (Let's call it 'Price range') on the index of type "Grouping" and the groupings you want. See dump 1
    1. Run the index build to get the new data in the index. This will add an extra field to each product telling which group the price belongs.
  2. In your query, create a new parameter of type string[], let's call it 'pricerange'. Add an expression using the "Price range" field 'matching any' of the parameter 'pricerange'. See dump 2
  3. In your facet setup, add a new facet, let's call it "Price", choose the Price range field and the pricerange parameter, see dump 3
  4. In the frontend you now get a new facet with the ranges and the number of products in each range, see dump 4
  5. You can now start adding values to the querystring parameter - and since the parameter is an array, you can seperate more price ranges using a comma. See dump 5

That's it. It can of course not handle discounts and customer specific prices as they are calculated at index time not being in the context of a user.

 

BR Nicolai

Capture.PNG Capture1.PNG Capture2.PNG Capture3.PNG Capture4.PNG
Votes for this answer: 1
 
Dynamicweb Employee
Carsten Boll
Reply

Hi Thomas - you can also go through our ranges how-to - and let me know if you have any comments re the guide :)

 
Thomas Larsen
Reply

Hi Carsten,

 

I have tried that and it works fine :-). But I was looking for the interval functionality.

And one thing with your range example, I’m missing the possibility to see min. and max. value for the products in the list

 

BR.

Thomas

 

You must be logged in to post in the forum