I recently upgraded a clients website from to and I have noticed I am getting the following error message when trying to save a product. I am stumped as to how I would fix this. My Upgrade process included a fresh install of Magento which updated the old DB.

SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (clientupgrade/catalogrule_group_website, CONSTRAINT FK_CATRULE_GROUP_WS_RULE_ID_CATRULE_RULE_ID FOREIGN KEY (rule_id) REFERENCES catalogrule (rule_id) ON DELETE CASCADE ON UPDATE CA)

I hope you guys can help.

  • Is it exact message which you get? clientupgrade/catalogrule_group_website doesn't look like a valid table name in magento db. – Dmytro Zavalkin Oct 9 '13 at 20:34
  • clientupgrade is the DB name. – Paul Donnelly Oct 10 '13 at 9:17
  • Looks like inconsistent data. Some FK were added during the upgrade process, but you have inconsistent data in those tables. Do some selects and see orphan records and delete them. – FlorinelChis Oct 10 '13 at 10:13
  • 1
    I think you should write your comment as answer and accept it, for people who have the same issue. – Dmytro Zavalkin Oct 10 '13 at 19:54

Thanks guys. I got it fixed. Turned out catalogrule_product and catalogrule_product_price had rule_id's that were not in catalogrule. I truncated catalogrule_product and catalogrule_product_price and applied the rules again via the admin to regenerate them.

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.