Replace SEO URL generation in EPiServer Commerce 7.5
EPiServer Commerce 7.5 offers two different approaches for routing to catalog content: The hierarchical route using the Name in URL property of the ancestor contents, and the SEO URL which has been fused with the Simple address system you know from EPiServer CMS. So the former will be on the format /catalog/category/subcategory/product and the latter a single URL segment. Which one is used when rendering links depends on how you register the catalog routes, see the routing article in the Commerce SDK / Developer Guide for more information.
By default the SEO URL is generated from the name of the content, with the “file extension” .aspx appended. To make the URLs unique per language branch, the language name may also be appended, to generate something like Red-Striped-Shirt-en.aspx.
Generating your own SEO URLs
The SEO URL generation is handled by the Mediachase.Commerce.Catalog.Data.UniqueValueGenerator class. You can override the generating bit in your own class:
The overridden SuggestSeoUri method will be called repeatedly until it generates a unique value. The index parameter is incremented by one for each call, and the duplicateUri parameter is set to the value which was checked in the previous pass (it will be null in the first call). As you can see I completely ignore the languageCode parameter, which means two language versions may vary only by a number in the URLs (product-name-1 and product-name-2).
To make use of your implementation you need an initialization module to replace the configuration in the container: