Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Integrity constraint violation: 1062 Duplicate entry ‘38577-401-1-579’ for key ‘PRIMARY’ when trying to reindex attributes through command line
 
goed_ballwin
Jr. Member
 
Total Posts:  8
Joined:  2011-12-05
 

Hi, I am uncertain how this happened and I have tried everything I can find on the forums (which isn’t much) to try to get this fixed. Every time I try to run #php /var/www/html/shell/indexer.php --reindex catalog_product_attribute to reindex my product attributes, I get the following error:

Product Attributes index process unknown error:
exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '38577-401-1-579' for key 'PRIMARY'' 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/lib/Zend/Db/Statement.php(300): Varien_Db_Statement_Pdo_Mysql->_execute(Array)
#3 /var/www/html/lib/Zend/Db/Adapter/Abstract.php(479): 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(419): Zend_Db_Adapter_Pdo_Abstract->query('INSERT INTO `ca...', Array)
#6 /var/www/html/app/code/core/Mage/Catalog/Model/Resource/Product/Indexer/Eav/Source.php(162): Varien_Db_Adapter_Pdo_Mysql->query('INSERT INTO `ca...')
#7 /var/www/html/app/code/core/Mage/Catalog/Model/Resource/Product/Indexer/Eav/Source.php(83): Mage_Catalog_Model_Resource_Product_Indexer_Eav_Source->_prepareSelectIndex(NULL, NULL)
#8 /var/www/html/app/code/core/Mage/Catalog/Model/Resource/Product/Indexer/Eav/Abstract.php(50): Mage_Catalog_Model_Resource_Product_Indexer_Eav_Source->_prepareIndex()
#9 /var/www/html/app/code/core/Mage/Catalog/Model/Resource/Product/Indexer/Eav.php(185): Mage_Catalog_Model_Resource_Product_Indexer_Eav_Abstract->reindexAll()
#10 /var/www/html/app/code/core/Mage/Index/Model/Indexer/Abstract.php(143): Mage_Catalog_Model_Resource_Product_Indexer_Eav->reindexAll()
#11 /var/www/html/app/code/core/Mage/Index/Model/Process.php(209): Mage_Index_Model_Indexer_Abstract->reindexAll()
#12 /var/www/html/app/code/core/Mage/Index/Model/Process.php(255): Mage_Index_Model_Process->reindexAll()
#13 /var/www/html/shell/indexer.php(158): Mage_Index_Model_Process->reindexEverything()
#14 /var/www/html/shell/indexer.php(198): Mage_Shell_Compiler->run()
#15 {main}

Next exception 'Zend_Db_Statement_Exception' with message 'SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '38577-401-1-579' for key 'PRIMARY'' 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/lib/Zend/Db/Statement.php(300): Varien_Db_Statement_Pdo_Mysql->_execute(Array)
#2 /var/www/html/lib/Zend/Db/Adapter/Abstract.php(479): 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(419): Zend_Db_Adapter_Pdo_Abstract->query('INSERT INTO `ca...', Array)
#5 /var/www/html/app/code/core/Mage/Catalog/Model/Resource/Product/Indexer/Eav/Source.php(162): Varien_Db_Adapter_Pdo_Mysql->query('INSERT INTO `ca...')
#6 /var/www/html/app/code/core/Mage/Catalog/Model/Resource/Product/Indexer/Eav/Source.php(83): Mage_Catalog_Model_Resource_Product_Indexer_Eav_Source->_prepareSelectIndex(NULL, NULL)
#7 /var/www/html/app/code/core/Mage/Catalog/Model/Resource/Product/Indexer/Eav/Abstract.php(50): Mage_Catalog_Model_Resource_Product_Indexer_Eav_Source->_prepareIndex()
#8 /var/www/html/app/code/core/Mage/Catalog/Model/Resource/Product/Indexer/Eav.php(185): Mage_Catalog_Model_Resource_Product_Indexer_Eav_Abstract->reindexAll()
#9 /var/www/html/app/code/core/Mage/Index/Model/Indexer/Abstract.php(143): Mage_Catalog_Model_Resource_Product_Indexer_Eav->reindexAll()
#10 /var/www/html/app/code/core/Mage/Index/Model/Process.php(209): Mage_Index_Model_Indexer_Abstract->reindexAll()
#11 /var/www/html/app/code/core/Mage/Index/Model/Process.php(255): Mage_Index_Model_Process->reindexAll()
#12 /var/www/html/shell/indexer.php(158): Mage_Index_Model_Process->reindexEverything()
#13 /var/www/html/shell/indexer.php(198): Mage_Shell_Compiler->run()
#14 {main}

I have tried looking for issues in the catalog_product_entity_int and catalog_product_index_eav and cannot find any. I have also tried deleting the listed product and the error just ticks up one to the next product.

We are unable to use navigation until I get this index updated. Anyone have any suggestions?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Zurd
Member
 
Total Posts:  31
Joined:  2012-10-18
 

something’s wrong with 38577-401-1-579

you have to find the table where it is and to what products it is attached to (might not be a product) and you probably have to do some SQL to fix it. Check out the errors folder, there might be something useful in it.

 
Magento Community Magento Community
Magento Community
Magento Community
 
goed_ballwin
Jr. Member
 
Total Posts:  8
Joined:  2011-12-05
 

Thanks but it is the entire catalog not just this product. It is product. 38577 is the prodict ID, 401 is the attribute ID, 1 is the store ID and 579 is the attribute option ID. This correlation exists in the catalog_product_entity_int table, but nothing is wrong there.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Zurd
Member
 
Total Posts:  31
Joined:  2012-10-18
 

I’d try to delete the product in the dashboard, else I would delete it in SQL, something must be wrong with it.

 
Magento Community Magento Community
Magento Community
Magento Community
 
goed_ballwin
Jr. Member
 
Total Posts:  8
Joined:  2011-12-05
 

Thanks. I did that and it just cycled to the next one. I actually did it for 4 products and it just popped the error on the next.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Zurd
Member
 
Total Posts:  31
Joined:  2012-10-18
 

pretty much out of my league now, but since it was working before, maybe you can find what is the latest product added and check them to see if there’s any inconsistency ?

 
Magento Community Magento Community
Magento Community
Magento Community
 
indiacakes
Jr. Member
 
Total Posts:  3
Joined:  2012-08-20
 

I am also getting the Same Error…
Has anyone resolved it yet?

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top