3

I'm having the following issue:

SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (db12038032-fsm.rating, CONSTRAINT FK_RATING_ENTITY_ID_RATING_ENTITY_ENTITY_ID FOREIGN KEY (entity_id) REFERENCES rating_entity (entity_id) ON DELETE CASCADE ON UPDATE CASCADE), query was: INSERT INTO rating (entity_id, rating_code, position) VALUES (?, ?, ?)

It pops up when I want to create a "rating" (Admin > Catalog > Ratings > Manage Ratings). (! Might not be the correct English expressions !)

Using Magento 1.9.1

Customers also can't add ratings in the frontend. There is also a error message like: "Review could not be transferred."

What I've already tried:

  • Magento DB-Repair-Tool
  • DROP TABLE rating, rating_entity.. and so on > then Magento DB-Repair Tool

I already tried to come to know SQL Syntax better but this error message has so many hints so that I'm struggling on which point I should work on. There might be any old module which makes some troubles, but I couldn't figure it out yet..

Your help is really appreciated!

1

It looks like the rating entity_id doesn't exist in your rating_entity table. Make sure the rating_entity table contains data:

entity_id     entity_code
1             product
2             product_review
3             review
  • Thanks for your reply. After hours of try and error it somehow worked. I had another Magento shop on 1.9.1 on which the review function was working fine. So I dropped the old tables in the corrupted database and used the Magento DB Repair Tool again (comparing the corrupted database and the database from my working shop). I'm really not sure why this wasn't working with a fresh clean database.. However, the table syntaxes were totally different. – eskaliert May 12 '15 at 12:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.