Try our conversational search powered by Generative AI!

Get the sort order from Entry

Vote:
 

Hello,

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?

#89658
Aug 21, 2014 16:10
Vote:
 

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:

entry[MetaDataProperties.PagePeerOrder];
#89662
Aug 21, 2014 18:05
Vote:
 

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)

Regards.

/Q

#89669
Aug 22, 2014 1:36
Vote:
 

Thanks for the answer, it worked :)

#89702
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.