我尝试更改 magento 订单商品数量,但不起作用。是否可以使用 Magento 自己的 API 更改订单商品数量,或者我是否需要使用一些自己的 SQL 来更改订单商品数量?
$order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
foreach($order->getAllItems() as $item)
{
$item->setToCancel(5);
$item->setToRefund(5);
$item->setToInvoice(5);
$item->setQtyToShip(5);
$item->setQty(5);
$item->save();
}
// Why qtys are still same and not 5 as set before???
foreach($order->getAllItems() as $item)
{
echo "Id : " . $item->getId() . "\r\n" .
"QtyToCancel : " . $item->getQtyToCancel() . "\r\n".
"QtyToRefund : " . $item->getQtyToRefund() . "\r\n".
"QtyToInvoice : " . $item->getQtyToInvoice() . "\r\n".
"QtyToShip : " . $item->getQtyToShip() . "\r\n".
"Qty : " . $item->getQty() . "\r\n";
}
最佳答案
在 magento 中,该过程如下:
- 下订单
- 要更改,请禁用订单
- 创建新订单
关于php - 是否可以在 Magento 中更新订单商品数量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12563078/