Is it possible to update order items quantity in Magento?

纵然是瞬间 提交于 2019-12-06 09:09:49

问题


I have tried to change magento order items quantity, but It doesn't work. Is it possible to change order items quantity using Magento own APIs, or do i need to use some own SQL in order to change order item quanties?

$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";                
}

回答1:


in magento the process is meant to be as follows:

  • make order
  • in order to change, disable order
  • create new order


来源:https://stackoverflow.com/questions/12563078/is-it-possible-to-update-order-items-quantity-in-magento

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!