Vishal Sharma
Vishal Sharma

Reputation: 1372

Cannot Update cart in magento 1.7.0.2

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

Upvotes: 1

Views: 413

Answers (1)

Vishal Sharma
Vishal Sharma

Reputation: 1372

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;
    

Upvotes: 1

Related Questions