Question

I have an observer for sales_order_place_after and this is working. Now I am generating an order myself and would like to trigger this event but it does not get to my observer.

Is something wrong here:

Mage::dispatchEvent('sales_order_place_after', array('order' => $service->getOrder()));

Or do I need to do something special from a external script file? My script looks like this.

Was it helpful?

Solution

Looks like my guess was correct.

In your config xml file you are only observing the event in one scope (for example frontend). However your script is running in a different scope. Placing the event into the global section of your config file should take care of this.

OTHER TIPS

Came across the same problem where the event wasn't fired in my external script.
Depending on the scope of your observer in the config.xml you have to set the Event Area.

require_once 'app/Mage.php';
Mage::init();

Mage::app()->addEventArea('global'); // e.g. 'global', 'frontend', 'adminhtml'
...

See also this article.

Replace the event to sales_order_save_after, this should be triggered from frontend, admin and custom scripts.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top