Quantcast
Channel: Developer to developer
Viewing all articles
Browse latest Browse all 9076

Catalog routing for product and category

$
0
0

Hello

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

Product directly on root:

{base-url}/en-gb/{product-segment}

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 :
                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?

Commerce v13.7.1

CMS v11.13.0

Thanks in advance,

Benjamin Sorterup


Viewing all articles
Browse latest Browse all 9076

Trending Articles