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 .GetRelationsBySource(entry.VariantsReference) .OfType () .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:
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)
Thanks for the answer, it worked :)
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?