小编Por*_*ail的帖子

sales_quote_add_item - 保存报价时出错

我在config.xml中有观察者sales_quote_add_item,当项目被添加到购物车时,它运行以下功能:

    public function updatePrice( $observer ){

        $event = $observer->getEvent();

        $quote_item = $event->getQuoteItem();

        $new_price = 200;
        $quote_item->setOriginalCustomPrice($new_price);
        $quote_item->setTotalPrice(350);

        $quote_item->save();
}
Run Code Online (Sandbox Code Playgroud)

如果用户已经注册,它工作正常,但如果我们作为访客,那么这一行

$quote_item->save();
Run Code Online (Sandbox Code Playgroud)

在var/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)
Run Code Online (Sandbox Code Playgroud)

我该如何解决?

magento

3
推荐指数
1
解决办法
3359
查看次数

标签 统计

magento ×1