1

For example, on Mage_Sales_Model_Order you have a method called sendNewOrderEmail() which runs this appEmulation, and generates the paymentBlocks to embed on the email. I was told that this is done to simulate the frontend store and precisely be able to generate said block...

but does the methods called under that appEmulation also trigger observers on my custom modules?

Thanks!

2 Answers2

3

In short, no. Area-specific events are enabled via the app->loadArea([AREA]) call in the action controller superclass preDispatch(); see Mage_Core_Controller_Varien_Action::preDispatch() (link). The areas are set by the child classes Mage_Core_Controller_Front_Action and Mage_Adminhtml_Controller_Action.

If dispatching code is evaluated during script execution (e.g. a call to Mage::dispatchEvent()) then the event is dispatched. However, if observers are configured as area-specific (e.g. frontend and adminhtml) then those events will not dispatch unless that area is loaded.

For the final bit of reference, see Mage_Core_Model_App_Emulation::startEnvironmentEmulation() and note that it does not call the load of an area.

benmarks
  • 23,384
  • 1
  • 62
  • 84
0

I've just been through the ringer trying to figure out exactly the same question you are asking. I was trying to build an external SSO login. I noticed that none of the controller events were firing in the Mage_Customer module etc. The same methods should apply to you, just determine which controller you want to emulate and make sure to dispatch the same events in your code.

I've posted the results of all my research here...

How can I trigger controllerless core Magento modules that watch <controller_action_predispatch> in <frontend> in config.xml from external script

In retrospect, you may have solved my problem in a similar method with this 'core/app_emulation' thing. I am going to have to look more into it.

Community
  • 1
  • 1
CarComp
  • 1,929
  • 1
  • 21
  • 47