Search code examples
shopware

shopware 6 article number with random string in url


In Shopware 6 I have this product url:

/{{ product.autoIncrement }}/{{ product.translated.name|lower}}/

As example: /1539/mercedes-benz/

Is it possible to make the productname free text? So if I enter the url /1539/mercedesbenzzz/ that I go to the same product?

I have tried to override SeoUrlPlaceholderHandlerInterface but I think this is not the right way. Any idea?


Solution

  • Overwriting SeoUrlPlaceholderHandlerInterface would not help, because this is for generating the URLs which are stored in the Shopware 6 database.

    What you want is to overwriting the routing, so Shopware only matches by the auto increment Id.

    Use the debug bar to find out which router is used for the product pages and modify it.

    Starting points:

    • \Shopware\Storefront\Framework\Routing\RequestTransformer::resolveSeoUrl

    • \Shopware\Core\Content\Seo\SeoResolver::resolve