Developer forum

Forum » Templates » New indexing and eCom templates

New indexing and eCom templates

René Poulsen
Reply

Hi,

I'm quite new to the new indexing and I'm currently working on a solution on version 8.7.2.5.

I want use the index and its facets to filter the products in the frontend. If i read the documentation it says: "To add facets to a template, use the Facets loop from figure XX below.". I've tried this in my eCom productlist template, but there are no facets shown. The paragraph with the ecom module is set up to use the index and I've added the facet I've created to the chosen facets.

Am I doing something wrong or am I running on a too old version of DW?


Replies

 
Nicolai Høeg Pedersen
Reply

Hi René

Attached a Razor template that loops products and also FacetGroups, Facets and Facet options (Note the 3 levels).

Also - on the Product Catalog Paragraph, when you have chosen a search, remember to choose at least one facet definition. See dump.

Capture.PNG
 
René Poulsen
Reply

Hi Nicolai,

Hmmmm... Not working here. I'm probably missing something else. I've attached a screenshot of my paragraph module setup. I've tried with and without the "Show facet options without results" checkbox checked.

I've put this in my product list template and nothing is shown:

@foreach (LoopItem facetGroup in GetLoop("FacetGroups")) {
        foreach (LoopItem facetItem in facetGroup.GetLoop("Facets")) {
            <span>@facetItem.GetString("Facet.Name")</span>

            foreach(LoopItem FacetOption in facetItem.GetLoop("FacetOptions")) {
                <span>@FacetOption.GetString("FacetOption.Name")</span>
            }
        }
    }

module-setup.jpg
 
Nicolai Høeg Pedersen
Reply

Hi René

I think it is an error in your Razor template.

When you write @foreach that is writing directly to your template.

Try changing it to a code block

@{

foreach (LoopItem facetGroup in GetLoop("FacetGroups")) {
        foreach (LoopItem facetItem in facetGroup.GetLoop("Facets")) {
            <span>@facetItem.GetString("Facet.Name")</span>

            foreach(LoopItem FacetOption in facetItem.GetLoop("FacetOptions")) {
                <span>@FacetOption.GetString("FacetOption.Name")</span>
            }
        }
    }

}

 
René Poulsen
Reply

Hi Nicolai,

It makes no difference. I still get nothing.

 
Nicolai Høeg Pedersen
Reply

Hi René

Just had another one like this where a facet was defined for a field that had too many values.

If a field has more than 2048 distinct values, it will not work. Could that be the case?

BR Nicolai

 
René Poulsen
Reply

I don't think that we're exceeding that limit.

I've got a parameter for group (we've got 196 groups in the shop) and for the customfields material and watt (I've got two for this one - one for min and one for max). I don't believe theese would exeed the 2048 distinct values, but is there any way I can check this easily?

 
Nicolai Høeg Pedersen
Reply

Gimme a link please - i'll find the error then :-)

 
René Poulsen
Reply

You've got mail :-)

 
Nicolai Høeg Pedersen
Reply
This post has been marked as an answer

It was the Groups checkbox that was enabled. See dump.

Capture.PNG
Votes for this answer: 1

 

You must be logged in to post in the forum