2012-10-23 34 views
3

我在config.xml中的觀察者sales_quote_add_item,當項目被添加到購物車下方運行功能錯誤在VAR此行sales_quote_add_item上保存報價

$quote_item->save(); 

報錯/ exception.log

2012-10-23T05:12:28+00:00 DEBUG (7): Exception message: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`bluning_mage`.`sales_flat_quote_item`, CONSTRAINT `FK_SALES_QUOTE_ITEM_SALES_QUOTE` FOREIGN KEY (`quote_id`) REFERENCES `sales_flat_quote` (`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE) 

如何我可以解決嗎?

回答

20

你不應該保存報價項目對象的觀察者,所以就刪除此行$quote_item->save(); 它會自動保存對象,因爲它是通過引用傳遞。

+0

謝謝,這是我的錯誤) –