Multiple catalog roots and cms roots



We have a requirement from a customer to handle different CMS structures and different Catalog rootes.

CMS Nodes:







And in the Commerce we have two different 2 catalogs (Private) and (Company) the url here can't be the same as CMS pages..we need to skip the first part in the url example:

/private/{CategoryName}/{SubCategory}/{Product} or /company/{CategoryName}/{SubCategory}/{Product}

How can i manage to resolve this issue? UrlRewriter? Custom HierarchicalCatalogPartialRouter?

Tnx in advance.

#174330 Jan 24, 2017 15:23
  • Per Gunsarfs
    Member since: 2005


    Thinking out load, cause I haven't actually tested this, but it might be possible by simply registering two HierarchicalCatalogPartialRouter.

    Normally you would use the CatalogRouteHelper.MapDefaultHierarchialRouter method to register the route. And that will register the route using the root catalog node. However, the HierarchicalCatalogPartialRouter does support starting in an arbitrary part of a catalog. So if you forgo the CatalogRouteHelper.MapDefaultHierarchialRouter, and instead register two routes manually, it think that should give you your desired behavior. The would be registered something like:

    RouteTable.Routes.RegisterPartialRouter(new HierarchicalCatalogPartialRouter(funcToGetPrivatePage, privateCatalogContent, false));
    RouteTable.Routes.RegisterPartialRouter(new HierarchicalCatalogPartialRouter(funcToGetCompanyPage, companyCatalogContent, false));

    I haven't actually tested it, so I might have missed something, but give it a try.


    Per Gunsarfs

    #174335 Jan 24, 2017 15:58
  • K Khan
    Member since: 2007

    From an old post, but still will work

    Theoratically only single definition will resolve the issue

    #174341 Jan 24, 2017 17:18

    Great i got it working with multible RegisterPartialRoute. But the url's is not getting resolved using UrlResolver.GetUrl() if i have two added. If i only add one the url's works but i need to have them both...

    The Code that adds the routes:

    // get the root page
    var rootPage = contentLoader.Get<PageData>(ContentReference.RootPage);

    // get the start page
    var startPage = contentLoader.GetChildren<PageData>(rootPage.ContentLink).FirstOrDefault();

    // get the different sub startpages /private /company
    var subStartPages = contentLoader.GetChildren<PageData>(startPage.ContentLink);

    foreach (var children in subStartPages)
         var existingCommerceCatalog = commerceRootContent.FirstOrDefault(x => x.Name.ToLower() == children.Name.ToLower());

         if (existingCommerceCatalog != null)
                    var hierarchicalCatalogPartialRouter = new HierarchicalCatalogPartialRouter(() => children.ContentLink, existingCommerceCatalog, false);

    Do i need to apply custom url resolving? 

    #174372 Edited, Jan 25, 2017 9:55
  • Tobias Sundqvist
    Member since: 2014

    @erikosterholm did you manage to solve the problem with UrlResolver.GetUrl() when having two HierarchicalCatalogPartialRouters? I'm experiencing the same problem.

    I'm trying to add two (or more) catalogs and each one having thier first node child as catalog start so i can customize the new "catalog rootpage" (because you can't inherit from CatalogContent).

    #177885 Apr 21, 2017 15:32
  • Carl S
    Member since: 2011

    From an old post, but still will work

    Theoratically only single definition will resolve the issue

    I'm curious if EPiServer have managed to enable having two HierarchicalCatalogPartialRouters? 

    We really want different url's for each catalog root.

    #189243 Mar 14, 2018 8:13
  • Quan Mai
    Member since: 2011

    No, that is still not something we (officially) support.

    #189250 Edited, Mar 14, 2018 9:30