[英]Magento V1.9 is running in timeout after sales_flat_quote_item update in event observer
I try to save additional information (from third-party-system) to sales_flat_quote_item
db in Magento V1.9.我尝试将其他信息(来自第三方系统)保存到 Magento V1.9 中的
sales_flat_quote_item
db。 The observer works fine.观察者工作正常。
The data which should be updated, were updated, but everytime it ends in an "Internal Server Error 500", even if I add a die()
after the $quoteItem->save();
应该更新的数据已更新,但每次都以“内部服务器错误 500”结尾,即使我在
$quoteItem->save();
之后添加了一个die()
$quoteItem->save();
There is no timeout when I comment $quoteItem->save();
当我评论
$quoteItem->save();
时没有超时$quoteItem->save();
out <- But then nothing was saved out <- 但随后什么也没有保存
config.xml配置文件
<events>
<sales_quote_item_save_commit_after>
<observers>
<MyCompany_MyProject_salesQuoteItemSaveCommitAfter>
<type>singleton</type>
<class>MyCompany_MyProject_Model_Observer</class>
<method>salesQuoteItemSaveCommitAfter</method>
</MyCompany_MyProject_salesQuoteItemSaveCommitAfter>
</observers>
</sales_quote_item_save_commit_after>
</events>
Observer.php观察者.php
/**
* @param Varien_Event_Observer $observer
*/
public function salesQuoteItemSaveCommitAfter($observer)
{
//var_dump($post); die();
$quoteItem = $observer->getEvent()->getItem();
//var_dump($quoteItem->getId()); echo die();
if (!$quoteItem->getId()) {
//quote not saved in the database
return $this;
}
//var_dump($quoteItem->getId()); die();
$quoteItem->setPriceInclTax($post['my_custom_price']);
$quoteItem->save();
return $this;
}
Yes exactly,对,就是这样,
The event sales_quote_item_save_commit_after is launched after each recording of the quote entity, here in the code when the $quoteItem->save();事件 sales_quote_item_save_commit_after 在每次记录报价实体后启动,这里在代码中 $quoteItem->save(); is launched, just after the observer is restarted and so on : which creates an infinite loop.
启动,就在观察者重新启动之后,依此类推:这会创建一个无限循环。
In this case you can instead use the sales_quote_item_save_before event or perform a check to verify that the PriceInclTax field has been recorded.在这种情况下,您可以改为使用 sales_quote_item_save_before 事件或执行检查以验证是否已记录 PriceInclTax 字段。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.