Hi All,
I hope someone can help me with a "Integrity constraint violation: 1452" error when trying to re-index. I have tried a couple of suggestions such as truncating the related tables but can't get this resolved. The whole error message is as follows when running the php reindexall command in /shell/indexer.php
Product Attributes index was rebuilt successfully in 00:00:00
Product Prices index process unknown error:
exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`dbtlshop_data`.`catalog_product_index_group_price`, CONSTRAINT `FK_CAT_PRD_IDX_GROUP_PRICE_ENTT_ID_CAT_PRD_ENTT_ENTT_ID` FOREIGN KEY (`entity_id`) REFERENCES `catalog_product_entity` (`entity)' in /home/dbtlshop/public_html/lib/Zend/Db/Statement/Pdo.php:228
Stack trace:
#0 /home/dbtlshop/public_html/lib/Zend/Db/Statement/Pdo.php(228): PDOStatement->execute(Array)
#1 /home/dbtlshop/public_html/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)
#2 /home/dbtlshop/public_html/app/code/core/Zend/Db/Statement.php(291): Varien_Db_Statement_Pdo_Mysql->_execute(Array)
#3 /home/dbtlshop/public_html/lib/Zend/Db/Adapter/Abstract.php(480): Zend_Db_Statement->execute(Array)
#4 /home/dbtlshop/public_html/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('INSERT INTO `ca...', Array)
#5 /home/dbtlshop/public_html/lib/Varien/Db/Adapter/Pdo/Mysql.php(428): Zend_Db_Adapter_Pdo_Abstract->query('INSERT INTO `ca...', Array)
#6 /home/dbtlshop/public_html/app/code/core/Mage/Catalog/Model/Resource/Product/Indexer/Price.php(498): Varien_Db_Adapter_Pdo_Mysql->query('INSERT INTO `ca...')
#7 /home/dbtlshop/public_html/app/code/core/Mage/Catalog/Model/Resource/Product/Indexer/Price.php(380): Mage_Catalog_Model_Resource_Product_Indexer_Price->_prepareGroupPriceIndex()
#8 /home/dbtlshop/public_html/app/code/core/Mage/Index/Model/Indexer/Abstract.php(143): Mage_Catalog_Model_Resource_Product_Indexer_Price->reindexAll()
#9 /home/dbtlshop/public_html/app/code/core/Mage/Index/Model/Process.php(212): Mage_Index_Model_Indexer_Abstract->reindexAll()
#10 /home/dbtlshop/public_html/app/code/core/Mage/Index/Model/Process.php(260): Mage_Index_Model_Process->reindexAll()
#11 /home/dbtlshop/public_html/shell/indexer.php(167): Mage_Index_Model_Process->reindexEverything()
#12 /home/dbtlshop/public_html/shell/indexer.php(215): Mage_Shell_Compiler->run()
#13 {main}
Next exception 'Zend_Db_Statement_Exception' with message 'SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`dbtlshop_data`.`catalog_product_index_group_price`, CONSTRAINT `FK_CAT_PRD_IDX_GROUP_PRICE_ENTT_ID_CAT_PRD_ENTT_ENTT_ID` FOREIGN KEY (`entity_id`) REFERENCES `catalog_product_entity` (`entity), query was: INSERT INTO `catalog_product_index_group_price` SELECT `gp`.`entity_id`, `cg`.`customer_group_id`, `cw`.`website_id`, MIN(IF(gp.website_id = 0, ROUND(gp.value * cwd.rate, 4), gp.value)) FROM `catalog_product_entity_group_price` AS `gp`
INNER JOIN `customer_group` AS `cg` ON gp.all_groups = 1 OR (gp.all_groups = 0 AND gp.customer_group_id = cg.customer_group_id)
INNER JOIN `core_website` AS `cw` ON gp.website_id = 0 OR gp.website_id = cw.website_id
INNER JOIN `catalog_product_index_website` AS `cwd` ON cw.website_id = cwd.website_id WHERE (cw.website_id != 0) GROUP BY `gp`.`entity_id`,
`cg`.`customer_group_id`,
`cw`.`website_id` ON DUPLICATE KEY UPDATE `price` = VALUES(`price`)' in /home/dbtlshop/public_html/lib/Zend/Db/Statement/Pdo.php:235
Stack trace:
#0 /home/dbtlshop/public_html/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)
#1 /home/dbtlshop/public_html/app/code/core/Zend/Db/Statement.php(291): Varien_Db_Statement_Pdo_Mysql->_execute(Array)
#2 /home/dbtlshop/public_html/lib/Zend/Db/Adapter/Abstract.php(480): Zend_Db_Statement->execute(Array)
#3 /home/dbtlshop/public_html/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('INSERT INTO `ca...', Array)
#4 /home/dbtlshop/public_html/lib/Varien/Db/Adapter/Pdo/Mysql.php(428): Zend_Db_Adapter_Pdo_Abstract->query('INSERT INTO `ca...', Array)
#5 /home/dbtlshop/public_html/app/code/core/Mage/Catalog/Model/Resource/Product/Indexer/Price.php(498): Varien_Db_Adapter_Pdo_Mysql->query('INSERT INTO `ca...')
#6 /home/dbtlshop/public_html/app/code/core/Mage/Catalog/Model/Resource/Product/Indexer/Price.php(380): Mage_Catalog_Model_Resource_Product_Indexer_Price->_prepareGroupPriceIndex()
#7 /home/dbtlshop/public_html/app/code/core/Mage/Index/Model/Indexer/Abstract.php(143): Mage_Catalog_Model_Resource_Product_Indexer_Price->reindexAll()
#8 /home/dbtlshop/public_html/app/code/core/Mage/Index/Model/Process.php(212): Mage_Index_Model_Indexer_Abstract->reindexAll()
#9 /home/dbtlshop/public_html/app/code/core/Mage/Index/Model/Process.php(260): Mage_Index_Model_Process->reindexAll()
#10 /home/dbtlshop/public_html/shell/indexer.php(167): Mage_Index_Model_Process->reindexEverything()
#11 /home/dbtlshop/public_html/shell/indexer.php(215): Mage_Shell_Compiler->run()
#12 {main}
Catalog URL Rewrites index was rebuilt successfully in 00:00:00
Product Flat Data index was rebuilt successfully in 00:00:07
Category Flat Data index was rebuilt successfully in 00:00:00
Category Products index was rebuilt successfully in 00:00:00
Catalog Search Index index was rebuilt successfully in 00:00:00
Stock Status index was rebuilt successfully in 00:00:00
Tag Aggregation Data index was rebuilt successfully in 00:00:00
Thanks in advance for any help or advice on what to do.
This issue has been resolved, please can a moderator close this thread? thanks.
I am having the same issue, can you explain how you solved this?
I resolved the same issue by truncating catalog_product_entity_group_price and rebuilding index again.
TRUNCATE TABLE `catalog_product_entity_group_price`;
and then using shell
php indexer.php --reindex catalog_product_price
Obviously, dont forget to take appropriate backups.
Thanks for the answer. The solution works.