This is my observer:

public function changeStatus(Varien_Event_Observer $observer)
        $order = $observer->getEvent()->getOrder();
        $getOrder =  Mage::getModel('sales/order')->load($order->getId());
        $OldOrder = Mage::getModel('sales/order')->load($getOrder->getData('relation_parent_id'));
        $OldOrder->setState('mystatushere', true)->save();


I used this event: sales_order_save_before or sales_order_save_after. I know the code is not optimized, so please don't blame me :D . What I want to achieve is to change the parent order status. I edit an order, make some modification and save it. A new order is created with increment-id-1 and when it this one is save I want to change the status of its parent order.

But I 'm receiving this: Fatal error: Uncaught Error: Call to a member function getMethodInstance() on boolean in app/code/core/Mage/Payment/Model/Observer.php:46. Any idea why ? thx


You are getting this error because $order = $observer->getEvent()->getOrder(); is not working.


$order = $observer->getEvent()->getOrder();
    $order->setState(Mage_Sales_Model_Order::STATE_NEW, true);

OR :

$order = $observer->getEvent()->getOrder();
      $orderModel = Mage::getModel('sales/order')->load($order->getId());
       $orderModel->setState(Mage_Sales_Model_Order::STATE_NEW, true);
  • If I do an echo $order->getId() I got the right id, so it works I also get the parent_id from $getOrder->getData('relation_parent_id'). – Attila Naghi Feb 6 '17 at 12:10
  • this line ` $OldOrder->setState(Mage_Sales_Model_Order::STATE_CANCELED, true)->save()` is the problem – Attila Naghi Feb 6 '17 at 12:10
  • better to use sales_order_place_after because order is not saved in sales_order_save_after – BornCoder Feb 6 '17 at 12:12
  • and no need to write save(); – BornCoder Feb 6 '17 at 12:14
  • check updated answer – BornCoder Feb 6 '17 at 12:15

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.