Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Sorting results of related products



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?



Jan 29, 2018 7:53

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.

Edited, Jan 29, 2018 8:11

Thanks that fixed it! :)

Jan 30, 2018 0:11

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.

Jan 30, 2018 14:35

Fixed in Commerce 10.8.1!

Edited, Feb 12, 2018 14:58
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.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.