by
Venkata Koppaka
| Oct 10, 2011
By default, Sitefinity Ecommerce ships with a date formatted URL for the Product Detail page, which comes very handy if you just want to let your users know when the product was published. But as with any other part of Sitefinity, this URL can be highly customized to meet your own needs and make even more Pretty URL or PURL in general.
You can change the default route of products in 2 ways
- 1. Using the urlFormat in the backend of Sitefinity
- 2. Extending OpenAccessCatalogDataProvider in your application
Below is the default URL format of products in Ecommerce
Using urlFormat in the backend of Sitefinity –
This option will let you extend the detail to not to have the date in the URL. To attain this URL format you would need to navigate to Backend-> Administration-> Settings-> Advanced-> Catalog->Providers-> OpenAccessProvider-> Parameters and then create a new parameter with the name urlFormat and value /[UrlName], this will change product detail URL to not have date. Please also note that new products added to the system will get new URL format by default but already existing products doesn’t change the URL by default. You will have to republish the existing products toget the new URL format. Below is a screenshot on how the new URL would look like -

Extending OpenAccessCatalogDataProvider -
This option will let you extend the route of product detail in any way you want. You have complete control over the route that leads to the detail page. Here is how you would do it –
- You will need to change the ProviderType to a custom class in your own application.
- Add the code to extend the route. (see example below)
| using Telerik.Sitefinity.GenericContent.Model; |
| using Telerik.Sitefinity.Modules.Ecommerce.Catalog.Data; |
| |
| namespace SitefinityWebApp |
| { |
| public class CustomProductRouteHandler : OpenAccessCatalogDataProvider |
| { |
| public override string GetUrlFormat(ILocatable item) |
| { |
| return "/[DetailRouteKey]/[UrlName]"; |
| } |
| |
| protected override string GetUrlPart<T>(string key, string format, T item) |
| { |
| if (key == "DetailRouteKey") |
| { |
| return "Detail"; |
| } |
| return base.GetUrlPart<T>(key, format, item); |
| } |
| } |
| } |

Above is an image on how the changed URL format would look like, please note that you can get the "DetailRouteKey" in any way you want and feed any string into the URL at this moment.
Also, as above note that new products added to the system will getnew URL format by default but already existing products doesn’t change the URLby default. You will have to republish the existing products to get the new URLformat.
Hope this helps,
Cheers
Venkata