【问题标题】:Magento 1.9 Change Order Status Uncaught ExceptionMagento 1.9 变更单状态未捕获异常
【发布时间】:2015-05-07 15:10:43
【问题描述】:

我正在使用 Magento 1.9 并且有一个负责运输的外部应用程序。产品发货后,一个文件会发送回我为 Magento 编写的监听器。我需要更新 Magento 订单状态以完成并使用以下代码,该代码基于 Stackoverflow 上的早期帖子

$order_num = Mage::getModel('sales/order')->load($id);

$order_num->setState(Mage_Sales_Model_Order::STATE_COMPLETE, true)->save();

我在这里遇到了以下问题

Uncaught exception 'Mage_Core_Exception' with message 'The Order State "complete" must not be set manually.

据我所知,这是因为订单状态受到保护。

我大部分时间都在寻找可能的解决方案,但无法弄清楚如何将订单状态更改为完成而不抛出错误。

如果有人能告诉我如何让它在 1.9 上工作,我将不胜感激

问候

理查德

【问题讨论】:

    标签: php exception-handling magento-1.9


    【解决方案1】:

    使用此代码。它对我有用..

    $order_num->setData('state', 'complete');
                          $order_num->setStatus('complete');
                          $history = $order_num->addStatusHistoryComment('', false);
    
    
                          $history->setIsCustomerNotified(false);
    
                          $order_num->save();
    

    【讨论】:

    • 小心,状态是Magento内部使用的。
    猜你喜欢
    • 2010-09-28
    • 2012-05-31
    • 2017-08-13
    • 1970-01-01
    相关资源
    最近更新 更多