Sorting results of related products

Vote:
 

Hi,

I can't find the answer to this one anywhere. Related Entries appears to be an orderable list within the CMS but using GetRelatedEntries() returns an IEnumerable which of course is unordered. Is there a way I can find out the order of these that appears within commerce?

Thanks!

Ben

#187574
Jan 29, 2018 7:53
Vote:
 

Which GetRelatedEntries method are you refering to? :) Are you talking about relations/associations for catalog content?

Edit: Found it! I assume you're doing it on the content itself via (EntryContentBaseExtensions.GetRelatedEntries(this EntryContentBase entry)). That will give you the Associations of that catalog content. I would probably recommend using IAssociationsRepository instead, as the Association object has a SortOrder you can use to order the items.

#187575
Edited, Jan 29, 2018 8:11
Vote:
 

Thanks that fixed it! :)

#187615
Jan 30, 2018 0:11
Vote:
 

EntryContentBaseExtensions.GetRelatedEntries should probably return the links sorted by the sortorder of the associations, much like ProductContentExtensions.GetVariants etc does for relations. I'll log a bug for it.

#187636
Jan 30, 2018 14:35
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.