1

Fatal error: Call to a member function getData() on a non-object

config.xml

    <events>
        <checkout_onepage_controller_success_action>
            <observers>
                <abandonedcart_observer>
                    <type>singleton</type>
                    <class>abandonedcart/observer</class>
                    <method>saveRedemptionInfo</method>
                </abandonedcart_observer>
            </observers>
        </checkout_onepage_controller_success_action>
    </events

Observer.php

public function saveRedemptionInfo(){

    $order_id = $observer->getData('order_ids');
    $order = Mage::getModel('sales/order')->load($order_id);

Same issue happens when I use sales_order_place_after and $order_id = $observer->getEvent()->getOrder()->getId(); . I get error-

Call to a member function getEvent() on a non-object

| improve this question | | | | |
1

you did a mistake in defining the function in the observer. You did not pass $observer as an argument to the observer function. You can call the function on the event sales_order_place_after like below :

public function saveRedemptionInfo($observer){

    $order = $observer->getEvent()->getOrder();
    echo "<pre>"; print_r($order->getData()); 
}
| improve this answer | | | | |

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.