Pick the right Catalog

Vote:
 

Hi

If I have 2 catalog under Root,
is it possible to tell Commerce in HierarchicalCatalogPartialRouter to choose witch Catalog to take from?

#220930
Apr 08, 2020 11:42
Vote:
 

HierarchicalCatalogPartialRouter includes the name of the catalog in the route, so I'd say this functionality is there out of the box. Example:

/catalog1/categoryA

/catalog2/categoryB

#220945
Apr 08, 2020 22:30
Vote:
 

Hi Juan,

Please try the below code hope it will work in your case.

The HierarchicalCatalogPartialRouter class constructor takes two parameters one is the route starting point and another commerce root (catalog root). In commerce root, we can try to pass the second catalog root and then check it's work or not.

  • Root/category1
  • Root/category2

CatalogContent secondCatalog = contentLoader.GetChildren<CatalogContent>(rootLink).Skip(1).FirstOrDefault();

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

RouteTable.Routes.RegisterPartialRouter(new HierarchicalCatalogPartialRouter(startLink, secondCatalog, false));
#221100
Apr 13, 2020 12:55
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.