我在magento面临一个大问题。
当我没有登录客户时,我可以更新购物车项目。但是当我与客户登录时,它会说无法更新购物车。
我启用了日志,它说: -
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)
请帮助
答案 0 :(得分:1)
我解决了这个问题,希望能有所帮助。请参阅此链接"How to change the foreign key referential action?"
我在我的数据库中运行两个查询,如下所示:
我只是从表中删除CONSTRAINT,然后在表中添加新的CONSTRAINT:
放弃旧:
ALTER TABLE `wishlist`
DROP FOREIGN KEY
`FK_WISHLIST_CUSTOMER_ID_CUSTOMER_ENTITY_ENTITY_ID`;
添加新内容:
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;