Magento – how to change magento order status programatically

fatal errormagento-1.9orders

I'm using magento 1.9 and I have to change the order status from shipped to delivered, both status having the same state "complete"

How can I able to change this?

I have tried following code

$order = Mage::getModel("sales/order")->loadByIncrementId(100000123);

$order->setData("state", "complete");
$order->setStatus("delivered");
$history = $order->addStatusHistoryComment('A ser executada a rotina de recarga.', false);
$history->setIsCustomerNotified(false);
$order->save();

But it gives

PHP Fatal error: Call to a member function getMethodInstance() on boolean in /app/code/core/Mage/Payment/Model/Observer.php on line 46

Best Answer

When I have got and error "The Order State "complete" must not be set manually." I found the solution here https://stackoverflow.com/questions/18711176/how-to-set-order-status-as-complete-in-magento

Related Topic