When product URLs behave unexpectedly, a direct look at Magento’s url_rewritetable can be useful. It stores public-facing paths, internal targets and redirects for product URLs.
Use the following query to display URL rewrites for a specific SKU:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
SELECT p.sku, u.store_id, s.code AS store_code, s.name AS store_name, u.request_path, u.target_path, u.redirect_type FROM url_rewrite AS u JOIN catalog_product_entity AS p ON u.entity_id = p.entity_id LEFT JOIN store AS s ON s.store_id = u.store_id WHERE u.entity_type = 'product' AND p.sku = 'MEINE-SKU' ORDER BY u.store_id, u.request_path; |
request_path contains the URL visible to customers, while target_path points to Magento’s internal target. The field store_id bzw. store_name identifies which store view each rewrite belongs to.
Several entries for one product are not necessarily duplicates or errors. Different store_id values usually mean Magento maintains separate rewrites for different store views.
Also useful is redirect_type. The value 0 means a normal rewrite without a redirect, 301 and 302 indicate permanent and temporary redirects respectively.
After changing URL keys, migrating or importing data, this query helps you see which rewrites Magento actually stores for a product.