Custom URL Rewrite
Composer kowal/module-customurlrewrite · Version 1.0.2
Product page
Description
Before a product repository save, check whether the URL key followed by .html already exists as a request path. On a collision, try successive numbered keys.
For whom
For administrators of catalogs using .html product URLs where similar product names can generate duplicate keys.
Features
- Check before a ProductRepository save.
- Try suffixes -1, -2 and so on.
- Store the selected URL key on the product.
Installation
From the Magento root, with Composer access to the Kowal package, run
composer require kowal/module-customurlrewrite
bin/magento module:enable Kowal_CustomUrlChecker
bin/magento setup:upgrade
bin/magento cache:clean
Configuration
- The module takes effect when enabled and has no separate configuration form.
- Check your product URL suffix. Version 1.0.2 looks for an exact request path built from the key and a fixed .html suffix.
- Before deployment, test resaving an existing product and saving in a second store view.
Requirements / notes
The lookup does not filter by product or store view. An existing path for the same product or another store view can also trigger a numbered key.
FAQ
Why did the key change when I saved a product without renaming it?
If the existing key followed by .html is already in the rewrite table, the module treats it as occupied. Compare the stored key and destination URL after each test save.
Verify the installation
bin/magento module:status Kowal_CustomUrlChecker
In a staging catalog containing model.html, save another product with the key model. If model-1.html is free, check for the key model-1 and open its URL. Save the product again and record the resulting key.