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: 1452 Cannot add or update a child row: a foreign key constraint fails
 
markf
Sr. Member
 
Total Posts:  145
Joined:  2007-09-20
 

SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`allsncom_staging/catalog_product_index_tier_price`, CONSTRAINT `FK_CATALOG_PRODUCT_INDEX_TIER_PRICE_ENTITY` FOREIGN KEY (`entity_id`) REFERENCES `catalog_product_entity` (`entity_id`) ON DELE)

Any ideas on why this is happening?  Its preventing me from rebuilding the product prices index

 
Magento Community Magento Community
Magento Community
Magento Community
 
Cole Geissinger
Sr. Member
 
Avatar
Total Posts:  174
Joined:  2008-12-23
Northern California
 

I have the exact same problem...any fixes?

 
Magento Community Magento Community
Magento Community
Magento Community
 
markf
Sr. Member
 
Total Posts:  145
Joined:  2007-09-20
 

I fixed mine by deleting some old tiered pricing entries from this table:

catalog_product_entity_tier_price

Cole Geissinger - 02 March 2010 01:43 PM

I have the exact same problem...any fixes?

 
Magento Community Magento Community
Magento Community
Magento Community
 
guido7
Member
 
Total Posts:  40
Joined:  2009-07-04
 

try going to System > Cache Management in admin panel and refreshing your cache, and clicking on all the various refresh/rebuild buttons under ‘Catalog’.  Then try adding a new product.

Don’t know what all these things do and which are necessary, but doing this worked for me

good luck

 
Magento Community Magento Community
Magento Community
Magento Community
 
moomoo
Sr. Member
 
Avatar
Total Posts:  192
Joined:  2009-07-10
 
markf - 02 March 2010 01:57 PM

I fixed mine by deleting some old tiered pricing entries from this table:

catalog_product_entity_tier_price

Cole Geissinger - 02 March 2010 01:43 PM
I have the exact same problem...any fixes?

Worked for me thanks a lot. I had some custom code on the old version to import tier prices, I guess that’s what caused the error.

 
Magento Community Magento Community
Magento Community
Magento Community
 
dan_lala
Member
 
Total Posts:  42
Joined:  2009-07-13
Germany
 

having t he same problem, but we have lots of tier prices (over 600) and deleting them all would be very ineffective. i hope there are other solutions, maybe only deleting the “wrong” tier price, but which is it?

 
Magento Community Magento Community
Magento Community
Magento Community
 
dan_lala
Member
 
Total Posts:  42
Joined:  2009-07-13
Germany
 

ok, found it via trial and error. apparently, we deleted some products with tier prices and the tier prices were still present in the table catalog_product_entity_tier_price.

 
Magento Community Magento Community
Magento Community
Magento Community
 
benz001
Sr. Member
 
Avatar
Total Posts:  238
Joined:  2009-02-05
Sydney
 

I had this problem on a version 1.6 store after deleting some products that didn’t have SKUs (they were half formed products created by people using the Duplicate product button).

To find the bad rows in the tier price table you can use some SQL like this:

SELECT 
  table1
.*, 
  
table2.sku as table2_sku,
  
table2.entity_id as table2_entity_id 
FROM 
`catalog_product_entity_tier_price` AS table1
LEFT JOIN
  
`catalog_product_entity` AS table2
ON
  table1
.entity_id table2.entity_id
WHERE
  table2
.entity_id IS NULL

So I first backed up my database, then deleted the couple of rows that were orphaned and then indexing worked again.
No idea how many other orphans may still be lurking in other tables though…

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