Department and Product URL rewrite
I've created some ecommerce products and I would liek to display them as normal pages (with the future option of turning them into ecommerce pages). For this I have the following page structure
Products (widgets: Departments, Product List)
- Product Detail (widgets: Product List - Single Item)
As part of this requirement I would like specific URLs for the departments and products.
For the department URL I would like the following
www.domain.com/.../
I have the following URL rewrite to handle this scenario
<rule name="Product Explorer Department Rewrite" stopProcessing="true">
<match url="^products/([^$]+)" />
<conditions>
<add input="URL" negate="true" pattern="action/edit" />
</conditions>
<action type="Rewrite" url="products/-in-department/departments/R:1" />
</rule>
For the product URL I would like the following
www.domain.com/.../product-name
Not sure how to approach this one.
I would also like these URLs to appear in any search results in the required format.
Thanks in advance for any ideas about how any of the above can be achieved.
Hello Sean,
I think you will find useful the following blog post where we provide more details about the custom url formats:
Custom URL Formats for Sitefinity Content Modules
The approach should be the same for the Products. In the Advanced settings, the module is called Catalog, there you will find the provider.
Here is also a sample which is based on the above blog post which you may find useful. The sample demonstrates how to achieve this by creating a custom provider for CatalogsModule (managing products). Please follow the below steps to register one:
1.Create a class inheriting OpenAccessCatalogDataprovider and override the GetUrlFormat like below, for the UrlFormat use the names of the fields available for products surrounded by square braces "[..]", this is how the url will be constructed:
using
Telerik.Sitefinity.Ecommerce.Catalog.Model;
using
Telerik.Sitefinity.GenericContent.Model;
using
Telerik.Sitefinity.Modules.Ecommerce.Catalog.Data;
namespace
SitefinityWebApp
public
class
CustomOpenAccessCatalogDataProvider : OpenAccessCatalogDataProvider
public
override
string
GetUrlFormat(ILocatable item)
Type itemType = item.GetType();
if
(
typeof
(Product).IsAssignableFrom(itemType))
//the url format is controlled here
return
"/[Price]/[UrlName]"
;
return
base
.GetUrlFormat(item);