Try our conversational search powered by Generative AI!

Shortening the Commerce Route (11.8.2)

Vote:
 

I have the following structure defined in the our build

This structure has 3 different catalogs which we've currently create as node off the main catalog rather than catalog themselves. Each one of these need to map to their own controller and also has some custom properties which is why we have not chosen to create them at direct catalogs.

Unfortunately this has caused our url structure to have /main-catalogue/ in the URL which I don't want. Is it easy to either. I've tried creating a type that inherited catalog with the hopes I could be able to create different types of catalog but it through an error

Can we remove this top catalog from the routing using custom routing in the URL so the URL off the domain can be

/course-catalogue/

/supplier-catalogue/

/donation-catalogue/

FYI I know the names aren't great and will be changing to our agreed IA

#190569
Edited, Apr 12, 2018 10:35
Vote:
 

Yes you can.

Check out https://leanpub.com/epicommercerecipes/read_sample 

Problem 1.5: Remove the catalog name from product url

#190570
Apr 12, 2018 10:47
Vote:
 

Thanks Quan, I think I actually read this a while ago but for the life of me couldn't remember where it was. I'll have a look at this, FYI do you know if it's on the roadmap to be able to create our own models for the top "Catalog" node? It would be great if we could extend this class to create our own

#190571
Apr 12, 2018 10:51
Vote:
 

We don't have a roadmap just yet, and it can be quite complicated to implement because of the underlying datastructure. What are the business scenarios when you need to extend CatalogContent? 

#190573
Apr 12, 2018 10:55
Vote:
 

As far as I undetstand the type of "Catalog" under tha root is designed for multiple catalogues and in this scenario each one of these might be it's own shop/product listing on the front end of the website. With all the other types you obviously create models with properties and we have core properties and a core ContentArea we add to evey type that ends up rendering as a page (common blocks, seo properties, social properties).

As the type under the root is locked down to a type we can't extend it's impossible to out of the box support any of this with multiple catalogs without doing what I've done and made these different catalog nodes under a common catalog instead.

I guess it just seems to me that that the root catalog should have the same flexibiliy of creating models and adding properties under the root as the CMS and site pages has without needing to change the routing and store them as nodes.

Unless I'm understanding their purpose wrong?

#190576
Apr 12, 2018 11:02
Vote:
 

I answered that last week IIRC. There is nothing prevents you to return a CMS page for a catalog content - which would be an easy implementation and have superior editing capabilities. 

#190577
Apr 12, 2018 11:08
Vote:
 

Sorry I'm not sure I follow there, all I want is the flexibility to define the top level node under the "Catalog Root" using C# Models as we do with NodeContent, ProductContent, VariationContent.

We already have everything working in commerce to support shared view model builders across our base types for type that inherit PageData, NodeContent, ProductContent, VariationContent that currently end up as rendered pages on the website. If we could model the "Catalog" node and create different types we could add these properties on here too so we always a consisten approach.

#190578
Apr 12, 2018 11:17
Vote:
 

Check out Problem 1.6.3: Beyond multiple sites 

#190579
Apr 12, 2018 11:24
Vote:
 

What I'm confused about in your example is the selection off the "Catalogue Root" node that show "New Catalog" seems restricted in code to "CatalogContent".

  [CatalogContentType(AvailableInEditMode = false, DisplayName = "Catalog Root", GUID = "c57885b5-c74c-4467-9ebf-4e56764dcb75")]
  [AvailableContentTypes(Include = new Type[] {typeof (CatalogContent)})]
  [CLSCompliant(false)]
  public class RootContent : NodeContentBase

How would the LandingNode in your example show as an allowed type on the "Catalogue Root"?

#190581
Apr 12, 2018 11:35
Vote:
 

I think I'll have to get your book, it's good some great info in :-)

#190582
Apr 12, 2018 11:38
Vote:
 

Hi again, I've implemented Problem 1.5: Remove the catalog name from product url as you suggested and routing is working however the generated URLs from the UrlResolver are still getting the wrong path. Does this require implementing our own hierarchical router as in 1.6.2?

#190583
Apr 12, 2018 12:05
Vote:
 

That's strange. UrlResolve would ask HierarchicalCatalogPartialRouter to generate the URL, and HierarchicalCatalogPartialRouter should already know it should exclude the catalog name. I'm in the middle of something, but I can check later. Possibly a bug, I just don't know yet.  

#190584
Apr 12, 2018 12:08
Vote:
 

Thanks Quan, appreciate the help :-)

#190585
Apr 12, 2018 12:10
Vote:
 

Don't worry about it, for some reason we had another InitalizationModule calling MapDefaultHierarchialRouter, once I removed this it's all working fine. Thanks for the help I think I can get everything working as expected now

#190586
Apr 12, 2018 12:26
Vote:
 
<p>Hi Quan, hopefully you'll still see this. We have noticed an issues around using the&nbsp;HierarchicalCatalogPartialRouter as suggested.</p> <p>We have multiple catalogs and I have routed them off 2 content pages from the CMS. But the second route always seems to not get mapped even though the code is executing</p> <pre class="brush:csharp;auto-links:false;toolbar:false" contenteditable="false"> var shopContentPageReference = siteConfigurationPageReference.ShopLandingPage; var courseContentPageReference = siteConfigurationPageReference.CourseLandingPage; if (!ContentReference.IsNullOrEmpty(courseRootCatalogReference) &amp;&amp; !ContentReference.IsNullOrEmpty(courseContentPageReference)) { var courseRootCatalog = ContentLoaderService.Service.Get&lt;CourseCatalogue&gt;(courseRootCatalogReference); Func&lt;ContentReference&gt; CourseStartingPoint = () =&gt; courseContentPageReference; routes.RegisterPartialRouter(new HierarchicalCatalogPartialRouter(CourseStartingPoint, courseRootCatalog, false)); } if (!ContentReference.IsNullOrEmpty(suppliesRootCatalogReference) &amp;&amp; !ContentReference.IsNullOrEmpty(shopContentPageReference)) { var suppliesRootCatalog = ContentLoaderService.Service.Get&lt;SupplierCatalogue&gt;(suppliesRootCatalogReference); Func&lt;ContentReference&gt; SuppliesStartingPoint = () =&gt; shopContentPageReference; routes.RegisterPartialRouter(new HierarchicalCatalogPartialRouter(SuppliesStartingPoint, suppliesRootCatalog, false)); }</pre> <p>I've tried swapping them and the route works fine for whichever one loads first but the second always seems not to set up correctly.<br /><br /></p> <p>These are 2 different catalogs&nbsp;</p> <p>Commerce</p> <ul> <li>main catalog <ul> <li>supplies</li> <li>courses</li> </ul> </li> </ul> <p>CMS</p> <ul> <li>Home <ul> <li>shop</li> <li>course landing</li> </ul> </li> </ul> <p>So that all the supplies are routed under the shop content page and all the&nbsp;courses under the source landing page. As I said they work exactly as I want for whichever is first loaded but the second is failing.</p>
#190723
Apr 16, 2018 14:36
Vote:
 

Yes I do (see this). Whenever you reply I will get a notification and I will try to reply back if I have time.

When you have multiple catalogs, it gets very tricky. You can't really remove the catalog name from the Url (at least I haven't try), but you can have a very short name for it. Look at other recipes in the sample, it would be there for you. 

#190724
Apr 16, 2018 14:43
Vote:
 

Thanks Quan, sorry to be a hassle on this but you seem the only one who really understands all this thoroughly

A little clarification, originally I was trying to get rid of the top level catalog name but I realised that our 2 catalogs needed to be routed to under different CMS content pages so that as shown the nodes under the supplies node (this is a node under the Catalog type) route to under the shop content page and the nodes under the courses node (also a node under the Catalog type) route to under the course landing page.

Thereforce as in the example code above I tried implementing 2 registrations for the HierarchicalCatalogPartialRouter to do this. This all seems to work fine but there seems to be a problem with having 2 of them, I found https://world.episerver.com/forum/developer-forum/Episerver-Commerce/Thread-Container/2017/1/multiple-catalog-roots-and-cms-roots-/ with a similar issue.

Will this likely manage to work if I implement something similar to your problem 1.6 in your examples for multiple catalogs? Essentially I just want the 2 nodes to route under 2 different site nodes.

#190725
Apr 16, 2018 14:59
Vote:
 

No worries, I try to help as much as I can. A quick question/answer which fit into 5 minutes break is fine for me. :) 

Now what I think you can do is return the CMS page in the catalog controller. How to know which page to return to is a bit tricky because you can't add properties to a CatalogContent, but you can of course have some kind of convention for that. Check out Problem 1.6.3: Beyond multiple sites

#190728
Apr 16, 2018 15:17
Vote:
 

I'm not sure that's going to work for us, our top level page for our catalogs need to support both content pages and commerce nodes. Is we were able to use the HierarchicalCatalogPartialRouter that would of works as we'd just using a content page for the root within the CMS and commerce items and child content pages would route through correctly. 

In your example your just loading through a content page but as far as I am aware I could achieve my goals as all the content pages under the "LandingNode" in your scenario would be routed to under the content page and I'd end up with 2 different seo URLs which I need to be the same. E.g. in your scenario

CMS

  • Home (https://www.example.com)
    • Landing Page (https://www.example.com/landing/)
      • Content Page (https://www.example.com/landing/content-page/)

If the LandingNode is just under the covers loading the Landing Page and the LandingNode (in the catlog) is routed under the Home page I'd have to have a unique name for the Landing Page and the Landing Node when what I want to achieve is that all the catalog content and child pages of the landing page route under the same URL.

#190729
Apr 16, 2018 15:35
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.