November Happy Hour will be moved to Thursday December 5th.

Custom routing

Vote:
 

Hi,

We have a catalog "games" with a hierarchy of nodes and then the products/variants.

Is it possible to change the urls to e.g /{catalog name}/{seo url} without writing a custom router?

I was hopeing to do something like this:

var hierarchicalCatalogPartialRouter =
new HierarchicalCatalogPartialRouter(() => gamesCatalog.ContentLink, commerceRootContent, true);

var partialRouteHandler = context.Locate.Advanced.GetInstance();

partialRouteHandler.RegisterPartialRouter(
new PartialRouter(hierarchicalCatalogPartialRouter));

RouteTable.Routes.RegisterPartialRouter(hierarchicalCatalogPartialRouter);

Thanks

#145680
Mar 09, 2016 18:56
Vote:
 

Hi,

No, I don't think that's possible without custom routing. You at least have to inherit from HierarchicalCatalogPartialRouter and do some magic there.

/Q

#145744
Mar 10, 2016 23:46
Vote:
 

Hi Quan,

thanks for your reply.

Do you perhaps know the most efficient way of getting an entry using the seo url?  There is GetCatalogEntryByUriDto but from another post that I've read it shouldn't be used when performance is a concern. 

How does Commerce resolve the seo url's?

Thanks

#145807
Edited, Mar 12, 2016 17:50
Vote:
 

Hi,

The Dto is cached so it's not that bad, I haven't measured it but I think it is not worse than loading content, at least not much. I think you can try it to see how it perform s in your site. You can always use your custom stored procedures and cache to improve performance.

We don't provide any equivalent feature in the new content API:s as they work with routesegment instead.

Regards,

/Q

#145809
Mar 12, 2016 21:22
Vote:
 

Hi Quan,

I was wonder if it would be possible to register a new mvc route e.g. /games/{seo uri} (where seo uri is the route segment) instead of overriding RoutePartial? 

Thanks

#145904
Mar 15, 2016 10:09
Vote:
 

Hi,

Theoretically, it should be possible. But you'll have two problems to solve:

- How to make sure your routing will catch the url before some other routers do that.

- How will you get the content from the RouteSegment. the RouteSegment is supposed to be unique within siblings. So it's possible to have both games/rpg/super-cool and games/action/super-cool.

Regards,

/Q

#145914
Mar 15, 2016 15:13
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.