2

我曾尝试更改 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";                
}
4

1 回答 1

2

in magento the process is meant to be as follows:

  • make order
  • in order to change, disable order
  • create new order
于 2012-09-24T10:25:46.190 回答