Magento – sales_order_place_after event not working

event-observermagento-1.9

I trying to execute my second observer which reacts to when Place order button has been clicked (sales_order_place_event). My first observer running good but second observer isn't. Could anybody tell me why? what am i doing wrong here?
config.xml

<events>
    <controller_front_init_before>
        <observers>
            <test_capture>
                <class>Foo_Test_Model_Observer</class>
                <method>capture</method>
                <type>singleton</type>
            </test_capture>
        </observers>
    </controller_front_init_before>
    <sales_order_place_after>
        <observers>
            <test_order>
                <class>Foo_Test_Model_Observer</class>
                <method>order</method>
                <type>singleton</type>
            </test_order>
        </observers>
    </sales_order_place_after>
</events>

Observer.php

class Foo_Test_Model_Observer {

    public function capture(Varien_Event_Observer $observer) {
        /*some code*/

    }

    public function order(Varien_Event_Observer $observer){

        echo __LINE__;exit;

    }
}

I tried to put my method in <controller_front_init_before> and run.. it works but my <sales_order_place_after> is not working

Best Answer

It happens in an ajax request, so you don't see the "echo" output in the frontend. If you inspect the response in the browser console you should see it.

I recommend to set up xdebug for step by step debugging. Then you can use a breakpoint instead of echo and exit. You also get information at runtime about variables and the call stack. It's really worth the initial effort.