I want to listen to an event by using an observer in my module. There are some other module observers as well which are listening the same event. So is there any particular order of firing the observer functions for this event? Or can I set is through the code to fire my modules observer function after some other observer function?

Any suggestions will be appreciated. Thanks in advanced.


2 Answers 2


The only way you can set order of the observers on the events is by module dependencies.
For example if you have one observer in the module Ns1_Module1 and one in Ns2_Module2 and you want the one in Ns2_Module2 to be fired first, you need to make Ns1_Module1 depend on Ns2_Module2 in app/etc/modules/Ns1_Module1.xml

                <Ns2_Module2 />
  • So there are no other alternative ways to do this? I knew this way. But didn't aware that this is the one and only way. Thanks a lot. Assume if we haven't provided this <depends> tag in module activation file, in that case which order will Magento fire the event observers?
    – Sukeshini
    Nov 5, 2013 at 9:15
  • 2
    @Su123 The observers will fire in the order they are loaded when initializing the config. Most probably in the alphabetical order of the files from app/etc/modules. This could be an other way to sort them. If you want the event from N1_M1 to fire later that N2_M2 just name the declaration file for N1_M1 to something else that is lower in alphabetical order than N2_M2. But I wouldn't go that way. It's becomes hard to manage.
    – Marius
    Nov 5, 2013 at 9:20
  • The order is determined in Mage_Core_Model_Config by $moduleFiles = glob($etcDir . DS . 'modules' . DS . '*.xml'); The documentation on this function does not mention it but I my tests the sort order has been alphabetically magebase.com/magento-tutorials/… - the depends nodes are factored in a bit later. Nov 5, 2013 at 16:29

If no dependencies are given, the order will be the alphabetical list of module-descriptions loaded from within app/etc/modules/.

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