Magento Forum

   
Page 1 of 3
SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`irciycom_magento/weee_discoun
 
partha
Jr. Member
 
Total Posts:  13
Joined:  2008-09-07
 

I found this error SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`irciycom_magento/weee_discount`, CONSTRAINT `FK_CATALOG_PRODUCT_ENTITY_WEEE_DISCOUNT_PRODUCT_ENTITY` FOREIGN KEY (`entity_id`) REFERENCES `catalog_product_entity` (`entity_id`) ON DELETE CASC).

Can any one help me to resolve this problem?. All my tables are in InnoDB.

 
Magento Community Magento Community
Magento Community
Magento Community
 
kulimuli
Sr. Member
 
Total Posts:  151
Joined:  2008-03-31
Linz, Oberösterreich
 

Hi, i have also this issue, could you fix this?

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

I am having the same issue, anyone found a fix?

 
Magento Community Magento Community
Magento Community
Magento Community
 
kulimuli
Sr. Member
 
Total Posts:  151
Joined:  2008-03-31
Linz, Oberösterreich
 

Hi, i found the error,

It seems this error is from an incorrect deleted product..., because in the table weee_discount are only lines till an incomplete (because deleted) existing product.
I restored my old database/website and search through all tableds with a “product_id” raw with following query (the catalog_category_product_index must be 2 times adjusted for each query). I deleted the reported lines.

After this the Update was successful.

SELECT
  
*
FROM
  catalog_category_product_index
LEFT
  JOIN
    catalog_product_entity
    ON catalog_category_product_index
.product_id catalog_product_entity.entity_id
WHERE
  catalog_product_entity
.entity_id IS NULL

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

Thanks for the tip, I will try that and see how it goes.

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

I tried the query and it found 3 items, I deleted them, but I still get the error below when trying to save a product.

SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`markfick_mage16/weee_discount`, CONSTRAINT `FK_CATALOG_PRODUCT_ENTITY_WEEE_DISCOUNT_PRODUCT_ENTITY` FOREIGN KEY (`entity_id`) REFERENCES `catalog_product_entity` (`entity_id`) ON DELETE CASCA)

 
Magento Community Magento Community
Magento Community
Magento Community
 
kulimuli
Sr. Member
 
Total Posts:  151
Joined:  2008-03-31
Linz, Oberösterreich
 

Hi,

the error was much profound as i thought.

After my Migration from one to another Server all Tables were MyISAM, but in MyISAM no Tablereferenzes exist’s.

1. i go back to a Version bevore Upgrade to 1.2 (1.1.8) with the Database and the Filesystem
2. changed all Engines (except the log tables) from MyISAM to InnoDB with the script i found in the forum (attached)
3. create a Database Backup
4. execute a Script (whith i extracted from the original Database from the Verion 1.1.8) to create all references (attached)
5. on much tabled i head inconsistencies (there the SQL Script from Point 4 stops whith an error), the inconsistent raws i found with the SQL Command i posted bevore
6. restore the Backup from point 3
7. fix the Error you found in point 5
8. go to step 3 unless all references in the Table created succesfull

good Luck if you have the same issue origin (spend min. 5 hours to fix :-( )!

Sorry for my bad english.

greetings from austria
kulimuli

File Attachments
beziehungen.sql  (File Size: 59KB - Downloads: 895)
 
Magento Community Magento Community
Magento Community
Magento Community
 
kulimuli
Sr. Member
 
Total Posts:  151
Joined:  2008-03-31
Linz, Oberösterreich
 

innodb-fix attachement.

File Attachments
innodb-fix.sql  (File Size: 10KB - Downloads: 2092)
 
Magento Community Magento Community
Magento Community
Magento Community
 
toman01
Sr. Member
 
Total Posts:  92
Joined:  2008-03-07
 

I also have the same error come up upon trying to save edits to my products.

I hired a programmer to try and fix it… he has spent countless hours trying to fix it to no avail.

Anybody have any suggestions? The Magento team maybe?

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

Still no luck for me either.  I have tried all the possible solutions offered by different people but I still get the error when trying to save a product in 1.2.0.3… Post back if you ever find a solution.  Thanks.

 
Magento Community Magento Community
Magento Community
Magento Community
 
toman01
Sr. Member
 
Total Posts:  92
Joined:  2008-03-07
 

Well let’s bump this post up… there’s got to be someone with the solution here tongue wink

 
Magento Community Magento Community
Magento Community
Magento Community
 
kulimuli
Sr. Member
 
Total Posts:  151
Joined:  2008-03-31
Linz, Oberösterreich
 

Hi, have you tried my solution? It’s a hard work but i think the only one way to bring your database in a consistent state, if your tables are in “MyISAM”. Magentocommerce is only supported with tables in “innodb”!

If you have a question, you can ask me anytime!

greetings from austria!
kulimuli

 
Magento Community Magento Community
Magento Community
Magento Community
 
markf
Sr. Member
 
Total Posts:  145
Joined:  2007-09-20
 
kulimuli - 01 February 2009 10:07 AM

Hi, have you tried my solution? It’s a hard work but i think the only one way to bring your database in a consistent state, if your tables are in “MyISAM”. Magentocommerce is only supported with tables in “innodb”!

If you have a question, you can ask me anytime!

greetings from austria!
kulimuli

Thanks for your efforts, but that did not fix it for me.  All my tables are innodb and I ran the sql you suggested.

 
Magento Community Magento Community
Magento Community
Magento Community
 
kulimuli
Sr. Member
 
Total Posts:  151
Joined:  2008-03-31
Linz, Oberösterreich
 

Hi markf,

innodb is one, look in your tables are there relations between other tables?
the most tables should have relations to other tables (http://www.magentocommerce.com/wiki/development/magento_database_diagram)

greetings from Austria…

 
Magento Community Magento Community
Magento Community
Magento Community
 
markf
Sr. Member
 
Total Posts:  145
Joined:  2007-09-20
 
kulimuli - 02 February 2009 10:39 AM

Hi markf,

innodb is one, look in your tables are there relations between other tables?
the most tables should have relations to other tables (http://www.magentocommerce.com/wiki/development/magento_database_diagram)

greetings from Austria…

Kulimuli, I am not sure exactly how to check that.  I did see foreign keys in there that referenced other tables if thats it what you mean.

 
Magento Community Magento Community
Magento Community
Magento Community
 
kulimuli
Sr. Member
 
Total Posts:  151
Joined:  2008-03-31
Linz, Oberösterreich
 

Hi,

in phpmyadmin go to a table, in my case “catalog_category_entity_varchar” in the midle of the right frame, i click the button “relation view”.

i attached a screenshot with my rerlations

Image Attachments
relations.jpg
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top
Page 1 of 3