1

I am facing a big problem in magento.

i am able to update the cart items when i am not login with the customer. but when i login with the customer then it says Cannot update the cart.

I enabled logs it says:-

exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint
violation: 1452 Cannot add or update a child row: a foreign key constraint 
fails
(`databasename`.`wishlist`, CONSTRAINT
 `FK_WISHLIST_CUSTOMER_ID_CUSTOMER_ENTITY_ENTITY_ID`
  FOREIGN KEY (`customer_id`)
 REFERENCES `customer_entity_old` (`entity_id`) ON DELETE CASCADE ON UPDATE CA)

Please Help

Rakib
  • 7,435
  • 7
  • 29
  • 45
Vishal Sharma
  • 1,372
  • 1
  • 8
  • 17

1 Answers1

1

I solved that problem hope its help. Please see this link "How to change the foreign key referential action?"

I run two queries into my Database as below:

I simply drop CONSTRAINT from the table, and then add the new CONSTRAINT in the table:

  1. Drop old:

    ALTER TABLE `wishlist`
    DROP FOREIGN KEY 
    `FK_WISHLIST_CUSTOMER_ID_CUSTOMER_ENTITY_ENTITY_ID`;
    
  2. Add new:

    ALTER TABLE `wishlist`
    ADD CONSTRAINT `FK_WISHLIST_CUSTOMER_ID_CUSTOMER_ENTITY_ENTITY_ID` 
    FOREIGN KEY (`customer_id`) 
    REFERENCES `customer_entity` (`entity_id`) 
    ON DELETE CASCADE ON UPDATE CASCADE;
    
Community
  • 1
  • 1
Vishal Sharma
  • 1,372
  • 1
  • 8
  • 17