Magento 1.9更改订单状态未捕获的例外情况

时间:2015-05-07 06:55:20

标签: php exception-handling magento-1.9

我正在使用Magento 1.9,并有一个外部应用程序负责运输。产品发货后,文件将被发送回我为Magento编写的监听器。我需要更新Magento Order状态以完成并使用以下代码,该代码基于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

上工作的话,我将不胜感激

此致

理查德

1 个答案:

答案 0 :(得分:0)

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

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


                      $history->setIsCustomerNotified(false);

                      $order_num->save();