Developer forum

Forum » Dynamicweb 9.0 Upgrade issues » User defined sorting of Ecom groups in frontend

User defined sorting of Ecom groups in frontend

Martin Christensen
Reply

Hi,

I've encountered that the sorting of Ecom groups in frontend is no longer reflective of the manual sorting in backend. Instead, groups are displayed alphabetically in the group list of the product catalog app. I've asked support about this and been told that this is the default behaviour from 9.9 and onwards.

Is there any workaround? The API for the group class doesn't seem to provide a property that holds the manual sort order.

We have a customer for whom this is pretty criticial, so we've made a quickfix adding a custom sort order field to the groups that we can sort by. But it's pretty tedious to maintain.

 

Best regards

Martin Christensen


Replies

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Hi Martin

Where are you in your code...? Can we see the context - is it a template, api call ?

The group class does not have a sort order since a group can be many times in the tree and have different sort order. So the sortorder for is on the group relation and not the group it self.

Thanks.

 
Martin Christensen
Reply

Sure, I'm working with the grouplist template for the product catalog app, ie. Ecom/GroupList/grouplist.cshtml

This is my current workaround - just sorting by group number, which I've then modified to reflect the desired order - not very maintainable:

@foreach(LoopItem g in GetLoop("Groups").OrderBy(o=>o.GetInteger("Ecom:Group.Number")).ToList()){
//show some groups
}

I could also do something like this:

var groups = Dynamicweb.Ecommerce.Services.ProductGroups.GetToplevelGroups().ToList();
groups.OrderBy(x => x.SomeParameter);

..to sort by any property of the Group class. Although I wouldn't necessarily want to display all toplevel groups.

 

You must be logged in to post in the forum