Developer forum

Forum » Development » GetGroups sorted by sort number

GetGroups sorted by sort number

Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi,

 

I am using services to GetTopLevelGroups() and then GetGroups() for the subgroups and everything works fine except the sorting.

 

I understand a group may belong to multiple parents, which may be the reason why it's not a property of the Group class, but is there any way I can get this? My UAT is to have my API generated data in the same order we see the group tree in the backend for a specific shop. Any ideas?

 

Best Regards,

Nuno Aguiar


Replies

 
Nicolai Pedersen
Reply

Hi Nuno

The service returns an Ienumerable of groups. Create a new instance of a groupcollection passing that ienumerable to the constructor and call SortByParentGroupOrder on the groupcollection.

GroupCollection: http://doc.dynamicweb-cms.com/api/html/1757341d-35e3-2600-503e-3b94e6e6ef2f.htm

BR Nicolai

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Nicolai,

 

I did that and my groups got sorted, but seems random now. I tried sorting the top level groups using the Sort() method instead, but it did not sort as expected

https://www.screencast.com/t/JcwpYjifNFZ

 

Any ideas if I am doing something wrong?

 

Best Regards,

Nuno Aguiar

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Nicolai,

 

Can you please take a look at my previous post? I don't know how else to sort the groups and/or what I might be doing wrong.

 

I was expecting to have the same order as the backend, but I can't.

 

Best Regards,

Nuno

 
Morten Bengtson Dynamicweb Employee
Morten Bengtson
Reply
This post has been marked as an answer

Hi Nuno,

Are the groups actually sorted? Check the EcomGroupRelations and EcomShopGroupRelation tables and see if the sorting values are different (is sorted) or all zeros (not sorted).

When you create groups using the UI the sorting value will be incremented each time. If you import the groups then you can specify the sorting in the import.

Best regards,
Morten

Votes for this answer: 1
 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Morten,

 

Top Level Groups

There are sorting values https://www.screencast.com/t/C2dhTgeAf1 Any idea?

 

Sub groups

You were right. In the EcomGroupRelations table everything was '0'.  I just clicked "Sort" and then "Save" to get the values I wonder why/how the UI got that sorting then, if it was not in the DB (all zeros) nor was it alphabetical.

 

Best Regards,

Nuno Aguiar

 
Morten Bengtson Dynamicweb Employee
Morten Bengtson
Reply
This post has been marked as an answer

Hi Nuno,

Try this: https://doc.dynamicweb.com/forum/development/development/get-groups-sorted-via-api-ecom#Reply59149

Best regards,
Morten

Votes for this answer: 1
 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Morten,

 

That solved the issue of the TopLevelGroups, so thank you very much.

 

Best Regards,

Nuno Aguiar

 

You must be logged in to post in the forum