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.
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: 220.127.116.11
Commerce version: 18.104.22.168
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: https://world.episerver.com/blogs/Magnus-Rahl/Dates/2015/3/routing-context-aware-links-in-commerce-catalog/
I also wrote about it here https://leanpub.com/epicommercerecipes/read_sample
I haven't read the blog post from Magnus (sorry!) but it might have same idea.