Magento是否可以更新订单商品数量? [英] Is it possible to update order items quantity in Magento?

查看:82
本文介绍了Magento是否可以更新订单商品数量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图更改magento订单项的数量,但这不起作用.是否可以使用Magento自己的API更改订单商品的数量,或者我需要使用一些自己的SQL来更改订单商品的数量?

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

推荐答案

在magento中,该过程的含义如下:

in magento the process is meant to be as follows:

  • 下订单
  • 要更改,请禁用订单
  • 创建新订单

这篇关于Magento是否可以更新订单商品数量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆