I'm trying to get the following URL structure for my Commerce:
Product directly on root:
Category path but without catalogue name:
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) ?
RouteTable.Routes.RegisterPartialRouter(new HierarchicalCatalogPartialRouter(startingPoint, commerceRootContent, false));
However I've been unsuccesful achieving the desired outcome. Anyone been succesful with this?
Thanks in advance,
There is a nice blog post about this, this will be helpful for you..
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.