Try our conversational search powered by Generative AI!

Catalog routing for product and category



I'm trying to get the following URL structure for my Commerce:

Product directly on root:


Category path but without catalogue name:

{base-url}/en-gb/{category-1-segment}/{category-2-segment} etc.

I've been able to remove the catalogue name with the following code in my initiallization module:

var referenceConverter = context.Locate.Advanced.GetInstance<ReferenceConverter>();
var contentLoader = context.Locate.Advanced.GetInstance<IContentLoader>();
var commerceRootContent = contentLoader.GetChildren<CatalogContent(referenceConverter.GetRootLink()).FirstOrDefault();
Func<ContentReference> startingPoint = () => ContentReference.IsNullOrEmpty(SiteDefinition.Current.StartPage) ?
                SiteDefinition.Current.RootPage :
RouteTable.Routes.RegisterPartialRouter(new HierarchicalCatalogPartialRouter(startingPoint, commerceRootContent, false));

However I've been unsuccesful achieving the desired outcome. Anyone been succesful with this?

Commerce v13.7.1

CMS v11.13.0

Thanks in advance,

Benjamin Sorterup

Dec 13, 2019 17:25

Hey Benjamin,

There is a nice blog post about this, this will be helpful for you..

Dec 16, 2019 9:02

Hey Benjamin,

There was a similar discussion in the past where community member had pointed out what Quan had explained in his book how to remove catalog from URL. you should follow that approach instead. That approach will ensure your URL structure will continue to work even when your product is directly underneath the catalog root.

~ Sujit

Dec 19, 2019 23:12
* 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.