Try our conversational search powered by Generative AI!

Get the sort order from Entry



How can I obtain the Sort Order integer established for a product (Entry class) programatically, so I can use that value for LINQ queries and ordering?

Aug 21, 2014 16:10

The sort order is stored in the relation, so you can have different sorting depending on from which node the entry is fetched.

This is an example on how to get the variations of a product, where you have the sort order:

var linksRepository = ServiceLocator.Current.GetInstance();

var relations = linksRepository
    .OrderBy(r => r.SortOrder);

You could do the same for nodes and get all the related entries.

I'm not sure, but the actual sort order might exist in the property:

Aug 21, 2014 18:05

WJohan's answer is correct, I would like to extens it a bit :

There are multiple kind of relations which have SortOrder:

- relation between node an entry, as stored in NodeEntryRelation table. 

- relation between entry and entry, for example, between a product and it variants. IIRC then it's stored in CatalogAssociation

- relation between nodes, stored in NodeRelation.

Depending on your requirement and your approach (DTO:s or content way), you can either get it from Relation object (via LinksRepository) or via SortOrder property (via Dto:s)



Aug 22, 2014 1:36

Thanks for the answer, it worked :)

Aug 22, 2014 12:52
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.