Developer forum

Forum » Ecommerce - Standard features » Filter ProductGroup Loops with Where

Filter ProductGroup Loops with Where

Adrian Ursu
Reply

Hi Guys,

I was wondering if I can do something like this to filter the ProductGroups loop:

@foreach(var tmp in GetLoop("ProductGroups").Where(Ecom:Group.Name = "filter_string")){

do something;

}

Actually I would like to know if I can do that for Product Loops as well.

 

Thanks,

Adrian


Replies

 
Dmitry Nikolenko
Reply

Hi Adrian,

Try follow example:

@foreach(var tmp in GetLoop("ProductGroups"))
{
    @if(tmp.GetString("Ecom:Group.Name") == "filter_string")
    {
        ...do something;
    } 

 
Adrian Ursu
Reply

Hi Dmitry,

Thanks a lot for the reply.

I already did that but I am afraid that performance wise it's not an elegant solution.

We expect to have a couple of thousand Groups in the list. Filtering the Loop at the source seemed more efficient than running a few thousand If's in the template.

I would still prefer filtering the initial list.

Any other thoughts?

Thank you,
Adrian

 
Nicolai Høeg Pedersen
Reply

No matter what, if you do the filtering in the template, the data is already there.

 

You must be logged in to post in the forum