SaaS CMS has officially launched! Learn more now.

Parent category on a product in an additional categories



I have a product which exists in two categories, and I'm having troubles getting the correct parent based on the context/url.

I can access the product from the two url below - which is great.

  • /en/catalog/private/lamps/test (primary)
  • /en/catalog/professional/lighting/test (additional category)

The problem arises when I'm trying to make a breadcrumb.

For it to work I need to be able to get the parent of the product, based on the url I'm on right now.

But I always end up with the primary category, which results in a wrong breadcrumb.

Understandably a ContentReference won't have enough information to determin which category I'm in, but is there another way to get the parent of the product?

By using currentPage.GetNodeRelations(); I can get a reference to both the parents, but I don't know which one of them is the correct one for the context I'm in.

Episerver version:

Commerce version:


Jun 12, 2018 17:30

You could simply look at the URL of the incoming request. Or build that into the routing. I did a very similar thing a couple of years ago, see this blog post:

Jun 12, 2018 22:39

I also wrote about it here

I haven't read the blog post from Magnus (sorry!) but it might have same idea. 

Jun 17, 2018 23:29
* 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.