I have x number of products that all belong to the same category node. Each product has a different sortorder set (I can see the value in Commerce Manager UI).
According to this blog post, CatalogRelationDto is the way to go to get hold of the sort order value. I've tried differect versions of the GetCatalogRelationDto method, but each time the NodeEntryRelation has 0 rows.
var catalogRelationDto = CatalogContext.Current.GetCatalogRelationDto(styleCatalogEntryId);
int sortOrder = catalogRelationDto.NodeEntryRelation.SortOrder;
There is no field or metadata field for SortOrder on the catalog entry. I can easily get hold of the catalog node that the entry belongs to, but no sortorder there either.
Any tips would be appreciated.
Correct link to blog post is:http://world.episerver.com/Blogs/The-Ensconced-Armamentarium/Dates/2012/6/Entry-SortOrder-Property-Where-Are-You/
I would like to suggest you use this overload instead: GetCatalogRelationDto(catalogId, catalogNodeId, entryCodeId, String.Empty, new CatalogRelationResponseGroup(CatalogRelationResponseGroup.ResponseGroup.NodeEntry)); You can only set the entryCodeId and leave catalogId and catalogNodeid to 0.
This overload guarantees that you will get the NodeEntryRelation table (which the ResponseGroup.NodeEntry parameter). The GetCatalogRelationDto(int catalogEntryId) only return the CatalogEntryRelation table. That's why you did not get any NodeEntryRelation row. And yes, you're correct to get/set SortOrer through the NodeEntryRelation row.
Thumbs up! ;)