触发事件sales_order_save_after
时,未插入新的数量值,这是什么问题?触发此事件时如何更新数量?事件两次被触发。
public function save_product_frontend($observer = null) {
$event = $observer->getEvent();
$order = $event->getOrder();
$items = $order->getAllItems();
foreach ($items as $item) {
$product = Mage::getModel("catalog/product")->load( $item->getProductId() );
$stockitem = Mage::getModel('cataloginventory/stock_item')->loadByProduct( $product );
$stockitem->setQty( 100 );
$stockitem->save();
}
}