Reputation: 24635
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
Reputation: 12750
in magento the process is meant to be as follows:
Upvotes: 2