php - 是否可以在 Magento 中更新订单商品数量?

标签 php magento magento-1.7

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

最佳答案

在 magento 中,该过程如下:

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

关于php - 是否可以在 Magento 中更新订单商品数量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12563078/

相关文章:

php - Magento 产品保存错误 事务尚未提交

Magento 1.7 验证码模块

phpfastcache V6 + redis - 可以设置前缀吗?

php - 创建 2x1 矩阵系统

php - LEFT OUTER JOIN SUM 双倍问题

php - Magento 加入不同的表

magento - 多商店设置 Magento 最大?

php - 如何在特定索引号处将对象(模型类型对象)插入到 Laravel 中的集合对象中?

php - 获取 Magento 类别 URL 和名称

magento - 无法在 Magento 中使用 TAX