Try our conversational search powered by Generative AI!

Ordering of Categories an Entry "Belongs To"



The strategy we're using is as follows: The first category an entry belongs to is the primary category (used for product breadcrumb/search), and the second category an entry belongs to will be is the brand category (used for faceting search and brand logos etc).

We manually created all the categories within EPiServer, and used the EPiServer service API to bring in some entries and assign them to categories. All good so far! When navigating to a category and "moving" a product to another category, we can confirm the intended behaviour works - the products' categories change in the correct order, e.g.

P1 belongs ot C1 and C2. If we navigate to C1 and "move" the P1 to C3, the P1 categories will be C3 and C2. As expected, all good!

However now if we create a new category (after the inital upload) and we navigate to C3, if we drag P1 into C4; the categories are now C2 and C4. This isn't ideal, as the ordering of categories is essential to our initial strategy, we'd expect them to be C4 and C2.

Is this intended behaviour? Could anyone provide some info, we don't want our customer navigating through hundreds of products every change :)



Aug 15, 2016 16:41

The Node-Entry relation SortOrder handling is currently not perfect. We're reworking the SortOrder of Node-Entry relation, so it'll be easier to sort that ordering the way you like. However this change will only be available in Commerce 10.



Aug 16, 2016 10:48

I have a similar problem: I need to change the 'Belongs to' order. The first category will be the main category for a product. Is this fixed in Service API 3?


Mar 16, 2017 22:26

Hi Erik,

You could potentially a bool on the category content type "IsMainCategory" - then just take the first category with the bool value as true.

Alternatively you could use the restful api to remove all relations, then add them in the new order.

Hope this helps!

Mar 17, 2017 9:32

We are working on "correcting" the relations between entry and the categories it belong to. That will be included in Commerce 11 (It was planned for Commerce 10 but did not make it, and it requires breaking changes so we can only include it in a major release)

Mar 17, 2017 9:38

I tried the solution to delete the categories and then add them in the reversed order but they end up in the same order. We haven't upgraded to epi 10 yet, will this be fixed do you think?


Mar 17, 2017 10:11

There isn't a fix for what you want in epi 10 - I'd recommend adding a bool to the categories to explicitly determine which is the main one 

Mar 17, 2017 10:15

I have an idea of using categories for trademark information for products. For the moment we have products in topcategory and subcategory. e.g. shirts/tshirts or shirts/sweaters. What do you think of using categories for brands e.g. brands/quicksilver or brands/jockey. In that case we could use the brands category as the main category and use that in canonical links for eample.

Mar 21, 2017 9:49

I am not entirely sure what you mean with categories.

If it is a data model that inherits from NodeContent i would simply suggest that you create another one for brands.

Having a seperate data model for brands comes with many advantages for one it will enable you to find the brand from all the other nodes regardless of order (unless you link same entry to more than one brand ^^).

Having a node 'brands' to collect them in is optional, it will make it easier to administrate but will require extra work at routing if you don't want it in your urls.

Mar 21, 2017 10:43

OK, thanks for the answer. I think we will do like that.

Mar 21, 2017 10:46
* 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.