Category sorting in Episerver Commerce

It is quite a standard requirement to sort product categories in a certain order. Customers might want to promote some categories more than others and display those on the top in the navigation or category listing. While Episerver doesn't have support for this yet, there is a solution.

At first, add a content area on your category type (or category base type if you have it). Limit content area items to catalog nodes, that only categories can be added to this content area.

Here I am loading all child categories of the parent category. Then extract content links from the content area items and retrieve corresponding child categories by these links. Also, ignore the links which do not have a matching child category by filtering items which are null. The loaded child categories should be in the same order as added to the content area.

Next, retrieve the unordered categories from the all child category list. And finally, create a common list by placing ordered categories in the front and unordered one at the end.

With this solution, editors now can add categories which they want on the top in the new content area. They can add these categories in a certain order. They also can add all categories and order those as needed.

While you can use this solution, it would be better to have a native Episerver support for this. I hope that Episerver will add it soon :).

Hi! I'm Māris Krivtežs. I am Web developer primarily working with ASP.NET, EPiServer and front-end development at Geta, but same time learning different programming languages, learning new programming paradigms, architectures, and design. I spend my free time with my family, reading books, bicycling and traveling.