我需要更改qty_invoiced
表中某个订单的sales_flat_order_item
列的值,但遗憾的是没有任何事情发生。
这是我的代码:
$allOrders = Mage::getModel('sales/order')->getCollection()
->addFieldToFilter('status', 'complete');
foreach ($allOrders as $value) {
$order = Mage::getModel('sales/order')->load($value->getId());
if($order->getincrementId() == '100000003'){
foreach ($order->getAllItems() as $item) {
$qtyOrdered = $item->getQtyOrdered();
$item->setQtyInvoiced($qtyOrdered);
}
}
}
答案 0 :(得分:0)
我认为您需要在设置新数量后保存项目和订单。
foreach ($allOrders as $value) {
$order = Mage::getModel('sales/order')->load($value->getId());
if($order->getincrementId() == '100000003'){
/** @var $item Mage_Sales_Model_Order_Item */
foreach ($order->getAllItems() as $item) {
$qtyOrdered = $item->getQtyOrdered();
$item->setQtyInvoiced($qtyOrdered);
$item->save();
}
}
$order->save();
}