newbie
newbie

Reputation: 24635

Is it possible to update order items quantity in Magento?

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

Upvotes: 2

Views: 3036

Answers (1)

Anton S
Anton S

Reputation: 12750

in magento the process is meant to be as follows:

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

Upvotes: 2

Related Questions