Developer forum

Forum » Ecommerce - Standard features » Grouping Facets

Grouping Facets

Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi guys,

I have a situation where the customer asks us to display the Facets grouped into different containers.

I know that Facets are rather flat as information structure but I was wondering if we can use the various Facet files definition from the Index for grouping:

The question is if I can find the file information in the list of facets (e.g. productList.FacetGroups) or even if I can access the definition on any other way.

Thank you,

Adrian


Replies

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

ProductListViewModel.FacetGroups should return that...:

https://doc.dynamicweb.com/apix/api/Dynamicweb.Ecommerce.ProductCatalog.ProductListViewModel.html#Dynamicweb_Ecommerce_ProductCatalog_ProductListViewModel_FacetGroups

One group for each facet file.

Swift just 'flattens' it like this:

if (productList.FacetGroups != null)
{
 foreach (FacetGroupViewModel facetGroup in productList.FacetGroups)
 {
 foreach (FacetViewModel facet in facetGroup.Facets)

 {

 if (facet.Options.Count() > 0)

 {

 facetsFound = true;


 foreach (FacetOptionViewModel option in facet.Options)

 {

 if (option.Selected)

 {

 selectedFacetsCount++;

 }

 }

 }

 }

 }

 }
 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Nicolai,

Thank you. I am not sure how I missed that. It was obvious that the FacetGroup is the source file :)

Thank you,
Adrian

 

You must be logged in to post in the forum