Magento Flat Indexing Fix

Fix for Magento error Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`db1`.`#sql-a211_565`, CONSTRAINT `FK_CAT_PRD_FLAT_1_ENTT_ID_CAT_PRD_ENTT_ENTT_ID` FOREIGN KEY (`entity_id`) REFERENCES `catalog_product_entity` (`entity_id`) ON DELETE CASCADE ON)'

Either

truncate table `catalog_product_flat_1`

or

DELETE pf1.*
FROM catalog_product_flat_1 pf1
LEFT JOIN catalog_product_entity p ON pf1.entity_id = p.entity_id
WHERE ISNULL( p.entity_id ) 

credit: http://www.avs-webentwicklung.de/nc/blog/artikel/magento-fehler-beim-index-aufbau-sofortmassnahmen.html

Leave a Reply

Your email address will not be published.