Developer forum

Forum » Ecommerce - Standard features » Facet terms sorting

Facet terms sorting

Maik Van Sark
Reply

Hi, 

I want to know if its possible to sort the results (terms) in a filter result?
I have added an orderby based on sort, but my sort value is always 0. By default its sorted alphabetically on the label.


Replies

 
Nicolai Pedersen
Reply

The sort property of facet options is only available for some kind of facets that comes out of Dynamciweb with a sort value - i.e. variant options (i.e. like color). 

I cannot see where your filters gets its data - it looks like values from product fields?

What would expect the sort property contained - and where should the value come from? 

Usuallay facet options are sorted by how many results a given option has in the search result or sorted by their name or, when supported, sorted by the sort property.

Technically only facets that gets their labels pretified by a "ValueMapper" can have the sort set - (see all ValueMappers here: https://doc.dynamicweb.com/api/html/8cff84d9-da7b-cc6e-4437-d35339345667.htm)

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi,

 

Allow me to jump in with a suggestion. The way I see it, we should be able to configure in the Facet, how we want the options to be sorted. That would give the possibility to configured them for each field:

  • Amount of results (default)
  • Label (to accomodate translations)
  • Value (when value are "0.25" but the label is "1/4" and we want to sort correctly)

 

Then obviously pick the direction to be Asc or Desc 

 

 

(Radio buttons or dropdown works just as fine)

 

Best Regards,

Nuno Aguiar

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

+1

 
Maik Van Sark
Reply

Ok thanks for the answers guys. 
Your right Nicolai, the filter data is data from custom product properties. The customer wants specific filter results (for the filter 'formaat') on top of the results, because those contain the most bought products.

Right now we show the first 5 filter options and hide the rest of the filter options. So im looking for custom sorting and not by name/value etc.
I was hoping there would be a database field to customize the sort because I saw a Sort property.

If you have other solutions or ideas, please let me know. I will think of something to realize the customers wishes.

 

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Maik,

 

If that's the case, you may try to use "List Facet" rather than a field facet. I wonder if the "sort" per field option works there.

You'd have to likely configure it for each distinct value, and might be a pain to maintain, but should get you what you need.

 

Best Regards,

Nuno Aguiar

 
Nicolai Pedersen
Reply

Hi Maik

In that case you can create a value mapper and add the sorting in that:

https://doc.dynamicweb.com/training/t3-platform-developer/t3-platform-developer/3-5-extending-indexing#5982

 

You must be logged in to post in the forum