3

Hello I am unable to get the order status in the observer sales_order_place_after I also tried other events like checkout_onepage_controller_success_action, checkout_type_onepage_save_order_after. Here is my code

<global>
<models>
  <xyz_customorderstatusmodel>
    <class>Endive_CustomOrderStatus_Model</class>
  </xyz_customorderstatusmodel>
</models>
<events>

  <checkout_submit_all_after>
    <observers>
      <xyz_CustomOrderStatus_Model_Observer>
        <type>singleton</type>
        <class>xyz_customorderstatusmodel/observer</class>
        <method>implementOrderStatus</method>
      </xyz_CustomOrderStatus_Model_Observer>
    </observers>
  </checkout_submit_all_after>
</events>

public function implementOrderStatus(Varien_Event_Observer $observer){
    $mytime = "time - " . date('d-m-Y H:i:s');
    Mage::log('in me');
    $status = $observer->getEvent()->getOrder()->getStates();
    Mage::log('My variable : '.$mytime .' -- ' .$status);
    die;

 }
1
  • I post answer kindly check. Commented Aug 10, 2018 at 14:27

2 Answers 2

3

You need to replace your code like this.

public function implementOrderStatus(Varien_Event_Observer $observer)
{
    $status = $observer->getEvent()->getOrder()->getStatus();
}
6
  • what is the error in my observer : paiza.io/projects/5wc-YEhCVOr3-YqB225yVA
    – zus
    Commented Dec 11, 2019 at 6:09
  • Do the small "P" into your Observer function like this one : public function checkorderstatus Commented Dec 11, 2019 at 6:18
  • After updated "p', still log not generated, paiza.io/projects/5wc-YEhCVOr3-YqB225yVA i am updated my code
    – zus
    Commented Dec 11, 2019 at 6:27
  • 1
    Put the log like this one : Mage::log($order->getCustomerFirstname(), null, 'orderproduct.log', true); Commented Dec 11, 2019 at 6:35
  • And also added this line : $observer->getEvent()->getOrder(); Commented Dec 11, 2019 at 6:36
2

Try the below code instead of yours:

public function implementOrderStatus(Varien_Event_Observer $observer){
    $status = $observer->getEvent()->getOrder()->getStatusLabel();
}

$observer->getEvent()->getOrder()->getStatusLabel(); This will return Status label like (Pending, Processing etc)

$observer->getEvent()->getOrder()->getStatus(); This will return Status Code(field values as in database) only like (pending, processing etc.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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