Hi,
I believe you can create your implementation of HierarchicalCatalogPartialRouter, which overrides the method
public virtual PartialRouteData GetPartialVirtualPath(CatalogContentBase content, string language, RouteValueDictionary routeValues, RequestContext requestContext)
when return the PartialRouteData, instead of StartPage
return new PartialRouteData { BasePathRoot = ContentReference.StartPage, PartialVirtualPath = seoUri };
}
You can set BasePathRoot to the products content link.
Then instead of using CatalogRouteHelper, register your new router:
var referenceConverter = ServiceLocator.Current.GetInstance<ReferenceConverter>();
var contentLoader = ServiceLocator.Current.GetInstance<IContentLoader>();
var commerceRootContent = contentLoader.Get<CatalogContentBase>(referenceConverter.GetRootLink());
routes.RegisterPartialRouter(new YourRouter(startingPoint, commerceRootContent, enableOutgoingSeoUri));
Warning: I did not try it, there's no guarantee it'll work, but it seems to be :)
Good luck.
/Q
Hi,
Thanks for your reply.
I have tried messing with that. However it seems that all the "GetPartialVirtualPath" does is to update the links in the CMS interface to point to http://<hostname>/products/categoryname/<productname>.aspx in the Hierarchial routing, not in the SEO routing.
I don't believe that the code in the HierarchicalCatalogPartialRouter is run when a producted is visited through the SEO URL.
Furthermore I am having a hard time looking up a product through the API, based on the SEO url.
Thanks again for your reply.
Hi,
ICatalogSystem (and its default implementation) has a method GetCatalogEntryByUriDto(string uri, string languageCode, CatalogEntryResponseGroup responseGroup); (and overloads). You can use it to get the content you need.
Not the most optimized way but it works :)
/Q
Yeah, I did read a blog post from this clever guy... and I generally got the feeling that ICatalogSystem should be avoided
http://world.episerver.com/Blogs/Quan-Mai/Dates/2014/10/Moving-away-from-ICatalogSystem-part-0/
Yes, it should be avoided when possible, but until we have complete replacement of ICatalogSystem in new content API:s, then, well...
:)
/Q
Hi guys
I have the same issue like Rene is having.
@Rene: Where you able to fix it?
Thanks
Juan
Hi,
I am setting up an EPiServer Commerce solution and I am having a problem changing the first part of the url for where the product pages are displayed. According to the documentation, you can use two routes:
Hierarchial urls (CatalogRouteHelper.MapDefaultHierarchialRouter(routes, false)) Which sets the product url to follow the category that the product is placed in
and
SEO urls (CatalogRouteHelper.MapDefaultHierarchialRouter(routes, true)) Which sets the product url to be in the root of the website, i.e. http:///.aspx
My request is simple and therefore I hope that the solution is as well.
How do I place the SEO approach under a path in the url. i.e. I want the SEO url to be placed under the path "products" so the url for all products becomes http:///products/.aspx
I recon it should be simple, but I can't seem to make it work.
Thanks for your time.