Magento – Duplicate Product URL Key

magento-1.9producturl-rewrite

I have products using the same URL Keys and I need a way to remove all of the URL Keys, so Magento regenerate them all according to their names.

Best Answer

You can use the following query to see which products have duplicate URL keys and how many duplicates there are:

SELECT COUNT(DISTINCT entity_id) AS amount, `value`, entity_id
FROM catalog_product_entity_varchar v
WHERE EXISTS (
  SELECT *
  FROM eav_attribute a
  WHERE attribute_code = "url_key"
  AND v.attribute_id = a.attribute_id
  AND EXISTS (
     SELECT *
     FROM eav_entity_type e
     WHERE entity_type_code = "catalog_product"
     AND a.entity_type_id = e.entity_type_id
  )
)
GROUP BY v.VALUE
ORDER BY `amount` DESC;

There is also a bug in the URL indexer that appends very large numbers to the end of URL's if duplicates exist, so you might want to look into that.

More information: https://erfanimani.com/issues-with-magentos-catalog-url-rewrite-indexer/

Related Topic