4

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

  • 1
    self resolved. $order = Mage::getModel('sales/order')->load($orderId); $order->addStatusHistoryComment('','delivered') ->setIsVisibleOnFront(false) ->setIsCustomerNotified(false); $order->save(); – Avinash Borse Aug 26 '16 at 10:10
  • I have tried above code , state and status field updated. But we get the error message as "Item (Mage_Sales_Model_Order) with the same id "325" already exist" require_once "app/Mage.php"; umask(0); Mage::app('default'); $order = Mage::getModel('sales/order')->load(403); $order->setData('state', "complete"); $order->setStatus("complete"); $order->save(); – Rat Dec 13 '17 at 6:14
0

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

5

you can change order status as below:

$orderId = YOUR_ORDER_ID;
$order = Mage::getModel('sales/order')->load($orderId);

$orderIncrementId = YOUR_ORDER_INCREMENT_ID;
$order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);

/**
 * change order status to 'Completed'
 */
$order->setState(Mage_Sales_Model_Order::STATE_COMPLETE, true)->save();

/**
 * change order status to 'Pending'
 */
$order->setState(Mage_Sales_Model_Order::STATE_NEW, true)->save();

/**
 * change order status to 'Pending Paypal'
 */
$order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, true)->save();

/**
 * change order status to 'Processing'
 */
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true)->save();

/**
 * change order status to 'Completed'
 */
$order->setState(Mage_Sales_Model_Order::STATE_COMPLETE, true)->save();

/**
 * change order status to 'Closed'
 */
$order->setState(Mage_Sales_Model_Order::STATE_CLOSED, true)->save();

/**
 * change order status to 'Canceled'
 */
$order->setState(Mage_Sales_Model_Order::STATE_CANCELED, true)->save();

/**
 * change order status to 'Holded'
 */
$order->setState(Mage_Sales_Model_Order::STATE_HOLDED, true)->save();
  • 1
    I tried this but it gives error "The Order State "complete" must not be set manually." I want to change status not state of order. – Avinash Borse Aug 25 '16 at 12:12
  • $order->setData('state', Mage_Sales_Model_Order::STATE_COMPLETE); $order->setStatus(Mage_Sales_Model_Order::STATE_COMPLETE); $history = $order->addStatusHistoryComment('Order was set to Complete by our automation tool.', false); $order->save(); – Alam Zaib May 17 '18 at 7:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.