Question

I get the following error when I try to reindex my Catalog URL Rewrites.

Product Attributes index was rebuilt successfully
Product Prices index was rebuilt successfully
Catalog URL Rewrites index process unknown error:
exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '0-hand-power-tools' for key 'UNQ_CATALOG_CATEGORY_ENTITY_URL_KEY_STORE_ID_VALUE'' in /var/www/html/lib/Zend/Db/Statement/Pdo.php:228
Stack trace:
#0 /var/www/html/lib/Zend/Db/Statement/Pdo.php(228): PDOStatement->execute(Array)
#1 /var/www/html/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)
#2 /var/www/html/app/code/core/Zend/Db/Statement.php(291): Varien_Db_Statement_Pdo_Mysql->_execute(Array)
#3 /var/www/html/lib/Zend/Db/Adapter/Abstract.php(480): Zend_Db_Statement->execute(Array)
#4 /var/www/html/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('INSERT INTO `ca...', Array)
#5 /var/www/html/lib/Varien/Db/Adapter/Pdo/Mysql.php(428): Zend_Db_Adapter_Pdo_Abstract->query('INSERT INTO `ca...', Array)
#6 /var/www/html/lib/Zend/Db/Adapter/Abstract.php(576): Varien_Db_Adapter_Pdo_Mysql->query('INSERT INTO `ca...', Array)
#7 /var/www/html/app/code/core/Mage/Catalog/Model/Resource/Url.php(392): Zend_Db_Adapter_Abstract->insert('catalog_categor...', Array)
#8 /var/www/html/app/code/core/Mage/Catalog/Model/Url.php(301): Mage_Catalog_Model_Resource_Url->saveCategoryAttribute(Object(Varien_Object), 'url_key')
#9 /var/www/html/app/code/core/Mage/Catalog/Model/Url.php(320): Mage_Catalog_Model_Url->_refreshCategoryRewrites(Object(Varien_Object), 'hand-power-tool...', false)
#10 /var/www/html/app/code/core/Mage/Catalog/Model/Url.php(320): Mage_Catalog_Model_Url->_refreshCategoryRewrites(Object(Varien_Object), '/', false)
#11 /var/www/html/app/code/core/Mage/Catalog/Model/Url.php(461): Mage_Catalog_Model_Url->_refreshCategoryRewrites(Object(Varien_Object), NULL, false)
#12 /var/www/html/app/code/core/Mage/Catalog/Model/Url.php(254): Mage_Catalog_Model_Url->refreshCategoryRewrite('3', '1', false)
#13 /var/www/html/app/code/core/Mage/Catalog/Model/Url.php(248): Mage_Catalog_Model_Url->refreshRewrites('1')
#14 /var/www/html/app/code/core/Mage/Catalog/Model/Indexer/Url.php(257): Mage_Catalog_Model_Url->refreshRewrites()
#15 /var/www/html/app/code/core/Mage/Index/Model/Process.php(210): Mage_Catalog_Model_Indexer_Url->reindexAll()
#16 /var/www/html/app/code/core/Mage/Index/Model/Process.php(258): Mage_Index_Model_Process->reindexAll()
#17 /var/www/html/shell/indexer.php(166): Mage_Index_Model_Process->reindexEverything()
#18 /var/www/html/shell/indexer.php(212): Mage_Shell_Compiler->run()
#19 {main}

Next exception 'Zend_Db_Statement_Exception' with message 'SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '0-hand-power-tools' for key 'UNQ_CATALOG_CATEGORY_ENTITY_URL_KEY_STORE_ID_VALUE'' in /var/www/html/lib/Zend/Db/Statement/Pdo.php:234
Stack trace:
#0 /var/www/html/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)
#1 /var/www/html/app/code/core/Zend/Db/Statement.php(291): Varien_Db_Statement_Pdo_Mysql->_execute(Array)
#2 /var/www/html/lib/Zend/Db/Adapter/Abstract.php(480): Zend_Db_Statement->execute(Array)
#3 /var/www/html/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('INSERT INTO `ca...', Array)
#4 /var/www/html/lib/Varien/Db/Adapter/Pdo/Mysql.php(428): Zend_Db_Adapter_Pdo_Abstract->query('INSERT INTO `ca...', Array)
#5 /var/www/html/lib/Zend/Db/Adapter/Abstract.php(576): Varien_Db_Adapter_Pdo_Mysql->query('INSERT INTO `ca...', Array)
#6 /var/www/html/app/code/core/Mage/Catalog/Model/Resource/Url.php(392): Zend_Db_Adapter_Abstract->insert('catalog_categor...', Array)
#7 /var/www/html/app/code/core/Mage/Catalog/Model/Url.php(301): Mage_Catalog_Model_Resource_Url->saveCategoryAttribute(Object(Varien_Object), 'url_key')
#8 /var/www/html/app/code/core/Mage/Catalog/Model/Url.php(320): Mage_Catalog_Model_Url->_refreshCategoryRewrites(Object(Varien_Object), 'hand-power-tool...', false)
#9 /var/www/html/app/code/core/Mage/Catalog/Model/Url.php(320): Mage_Catalog_Model_Url->_refreshCategoryRewrites(Object(Varien_Object), '/', false)
#10 /var/www/html/app/code/core/Mage/Catalog/Model/Url.php(461): Mage_Catalog_Model_Url->_refreshCategoryRewrites(Object(Varien_Object), NULL, false)
#11 /var/www/html/app/code/core/Mage/Catalog/Model/Url.php(254): Mage_Catalog_Model_Url->refreshCategoryRewrite('3', '1', false)
#12 /var/www/html/app/code/core/Mage/Catalog/Model/Url.php(248): Mage_Catalog_Model_Url->refreshRewrites('1')
#13 /var/www/html/app/code/core/Mage/Catalog/Model/Indexer/Url.php(257): Mage_Catalog_Model_Url->refreshRewrites()
#14 /var/www/html/app/code/core/Mage/Index/Model/Process.php(210): Mage_Catalog_Model_Indexer_Url->reindexAll()
#15 /var/www/html/app/code/core/Mage/Index/Model/Process.php(258): Mage_Index_Model_Process->reindexAll()
#16 /var/www/html/shell/indexer.php(166): Mage_Index_Model_Process->reindexEverything()
#17 /var/www/html/shell/indexer.php(212): Mage_Shell_Compiler->run()
#18 {main}
Category Products index was rebuilt successfully
Catalog Search Index index was rebuilt successfully
Stock Status index was rebuilt successfully
Tag Aggregation Data index was rebuilt successfully

How can I solve this?

Was it helpful?

Solution

Make a dump from you database: Step 1: On you ssh shell do this command:

mysqldump -h databasehost -u user -pPASSWORD databasename > filename.sql

Step 2: So you can try:

TRUNCATE core_url_rewrite;

And try reindex again.

This should do the trick.

OTHER TIPS

Do not truncate: core_url_rewrite

This is the worst advice ever, you will lose all customized SEO urls! Just dont do it!

What worked for me was SSH and running:

php -f ./shell/indexer.php -- -reindex catalog_url

If nothing else works then maybe attempt the table dropping idea, but only as a last resort!

I'm not certain why your truncate is getting interrupted, that's problematic. You can try rebuilding the index from the shell script from the main Magento directory:

php -f ./shell/indexer.php -- -reindex catalog_url

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top