SaaS CMS has officially launched! Learn more now.

Setting a NodeContent as the catalog root using the HierarchicalCatalogPartialRouter



I am trying to set the Node content as the catalog root. Below is my catalog structure:

I want to make the Test Node the root for all the children Node Contents under it. And below is my code 

using System;
using System.Configuration;
using System.Linq;
using System.Web.Routing;
using EPiServer;
using EPiServer.Commerce.Routing;
using EPiServer.Framework;
using EPiServer.Framework.Initialization;
using EPiServer.Web;
using EPiServer.Web.Routing;
using Mediachase.Commerce.Catalog;

namespace Foundation.Infrastructure
    public class Initialization : IInitializableModule
        public void Initialize(InitializationEngine context)
            var referenceConverter = context.Locate.Advanced.GetInstance<ReferenceConverter>();
            var contentRepository = context.Locate.Advanced.GetInstance<IContentRepository>();
            var rootLink = referenceConverter.GetRootLink();
            var root = contentRepository.GetChildren<EPiServer.Commerce.Catalog.ContentTypes.CatalogContent>(rootLink).FirstOrDefault();
            var rootNodeContent = contentRepository.GetChildren<EPiServer.Commerce.Catalog.ContentTypes.NodeContent>(root.ContentLink).FirstOrDefault();

            var hierarchicalCatalogPartialRouter = new HierarchicalCatalogPartialRouter(() => SiteDefinition.Current.StartPage, rootNodeContent, false);


        public void Uninitialize(InitializationEngine context)
            //Add uninitialization logic

But I still see the routing has not changed, it still is for exmaple:

Since I made the the first NodeContent the root, I was expecting it to be like:

Am I missing something here?

May 01, 2020 3:45

Hi Siddharth,

I have created another entry for Node in the RouteTable which works for both cases catalog and node. Please try.


    public class CatalogRoutingInitialization : IInitializableModule
        public void Initialize(InitializationEngine context)
            // Services
            ReferenceConverter referenceConverter = context.Locate.Advanced.GetInstance<ReferenceConverter>();
            IContentLoader contentLoader = context.Locate.Advanced.GetInstance<IContentLoader>();

            // Register catalog router (removes catalog string from URL)
            ContentReference rootLink = referenceConverter.GetRootLink();
            CatalogContent catalog = contentLoader.GetChildren<CatalogContent>(rootLink).FirstOrDefault();

            Func<ContentReference> startLink = () =>
                    ? SiteDefinition.Current.RootPage
                    : SiteDefinition.Current.StartPage;

            // catalog root content
            RouteTable.Routes.RegisterPartialRouter(new HierarchicalCatalogPartialRouter(startLink, catalog, false));

            // node root content 
            var rootNodeContent = contentLoader.GetChildren<NodeContent>(catalog.ContentLink).FirstOrDefault();
            var nodeCatalogContent = contentLoader.Get<CatalogContentBase>(referenceConverter.GetContentLink(rootNodeContent.Code));
            RouteTable.Routes.RegisterPartialRouter(new HierarchicalCatalogPartialRouter(() => rootNodeContent.ContentLink, nodeCatalogContent, false));

        public void Uninitialize(InitializationEngine context)

For more customization please follow Jakejon's post. 

May 01, 2020 19:18
Siddharth Gupta - May 03, 2020 6:27
Hi Sanjay, I tried this out but it did not work as well. Have you tried this on Foundation? Looks like this is not working on Foundation.
Sanjay Kumar - May 03, 2020 16:54
No, I tried in QuickSilver solution.

It looks like you are using Foundation? Then you might want to remove this line

this registers the default router which might interfere with your set up

May 03, 2020 20:34
Siddharth Gupta - May 03, 2020 23:36
Thanks Quan! :)
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.