Try our conversational search powered by Generative AI!

Default Sorting Order of Products in category - Using the CMS UI


On our product list pages the products returned seem to be in the order they were published.

Our normal sortng seems to work fine. 

case SortingType.Price:
search = search.OrderBy(p => p.SearchPrice());
case SortingType.PriceReverse:
search = search.OrderByDescending(p => p.SearchPrice());
case SortingType.TopRated:
search = search.OrderByDescending(p => p.AverageRating)
.ThenByDescending(p => p.ReviewCount);

We need the products to be returned in the order they appear in the CMS editor so that the content editors can visuall see and sort the products.

EPiServer Commerce Framework 
Version: 11.8 (build: 2)

Kind Regards


Edited, Oct 12, 2018 1:53

Sandeep, i am not sure I understand your question. So you want to show the products to the end users in the same order as they are shown to the editors?

Oct 12, 2018 8:04

Yes please

Oct 12, 2018 8:22

The products are sorted by the SortOrder to their respective category, so it is not a property in the products itself. This is a tricky problem I must admit - not sure I have good solution. You can of course writing a Sort method that loads the relations of the product, gets the sort order in the current category and then sorts by it. But it is not that elegant or simple ... 

Oct 12, 2018 9:38

Wanted to know that when indexing the products in EPi find it must insert it in the order they appear in the CMS I am presume.

Also could you please confirm that if no sorting is specified in the qury paramet what criteria does it use to return product. Is it by the latest publish date.

Oct 12, 2018 10:00

To get Node/Entry sortOrder

var nodeEntryRelations = _relationRepository.GetParents<NodeEntryRelation>([EntryContentLink]);
var relation = nodeEntryRelations.FirstOrDefault(r => r.Parent == [NodeContentLink]);

var sortOrder = relation.SortOrder;

Sep 10, 2019 13:06
* 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.