本文整理汇总了PHP中Mage_Sales_Model_Order_Shipment::_afterSave方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Order_Shipment::_afterSave方法的具体用法?PHP Mage_Sales_Model_Order_Shipment::_afterSave怎么用?PHP Mage_Sales_Model_Order_Shipment::_afterSave使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Sales_Model_Order_Shipment
的用法示例。
在下文中一共展示了Mage_Sales_Model_Order_Shipment::_afterSave方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _afterSave
/**
* Surcharge la méthode after save pour mettre a jour les stocks
*
* @return Mage_Core_Model_Abstract
*/
protected function _afterSave()
{
try {
//appel le parent
parent::_afterSave();
//Define if shipment just created
$creation = $this->getentity_id() != $this->getOrigData('entity_id');
if ($creation) {
//Create stock movements
$order = $this->getOrder();
foreach ($this->getAllItems() as $item) {
//retrieve informaiton
$qty = $this->getRealShippedQtyForItem($item);
try {
$StockMovement = mage::getmodel('Purchase/StockMovement')->setsm_product_id($item->getproduct_id())->setsm_type('order')->setsm_coef(-1)->setsm_qty($qty)->setsm_date(date('Y-m-d'))->setsm_ui($item->getId())->setsm_description(mage::helper('purchase')->__('Order #') . $this->getOrder()->getincrement_id())->save();
} catch (Exception $ex) {
//nothing, db constraint exception because stock movement already exists
}
//reset reserved qty
$orderItem = $item->getOrderItem();
$orderItem->setreserved_qty(0)->save();
}
//update order planning
$orderId = $this->getOrder()->getId();
mage::helper('BackgroundTask')->AddTask('Update planning for order ' . $orderId, 'purchase/Planning', 'updatePlanning', $orderId);
//Met a jour les qte commandées pour le produit
$order->UpdateProductsOrdererQty;
}
} catch (Exception $ex) {
mage::log($ex->getMessage());
}
return $this;
}