The only possibility to achieve this by declaring Module Dependency1 in your extension. Below I will show you the two cases which will help you to ORDER your observer in effective way.
Scenario
Let us call our module Namespace_Module
. Suppose you are observing to an event some_example_event_to_observe
. Now suppose below modules are also observing the same event.
- Mage_Cms
- Mage_Customer
- Namespace_Module
- SomeNamespace_SomeModule
- SomeOtherComapny_SomeOtherModule
Please note, without any module dependency, Magento is going observe the event in the same listed order
Case - I
You want your module observer should trigger only after observer of SomeNamespace_SomeModule
. For that case, your activation file will look like this.
File: app\etc\modules\Namespace_Module.xml
<config>
<modules>
<Namespace_Module>
<active>true</active>
<codePool>community</codePool>
<depends>
<SomeNamespace_SomeModule />
</depends>
</Namespace_Module>
</modules>
</config>
See the <depend />
tag. We just specified there that, our module depends on SomeNamespace_SomeModule
. Therefore Magento will process observer SomeNamespace_SomeModule
first and then consider our observer.
Case - II
We want our observer to listen at last. In this case, our module's activation file will look like
File: app\etc\modules\Namespace_Module.xml
<config>
<modules>
<Namespace_Module>
<active>true</active>
<codePool>community</codePool>
<depends>
<SomeNamespace_SomeModule />
<SomeOtherComapny_SomeOtherModule />
</depends>
</Namespace_Module>
</modules>
</config>
Since we specified our module now depends on SomeNamespace_SomeModule
and SomeOtherComapny_SomeOtherModule
, our module is going to load last.
Case - III
We need to trigger our event very first. In that case
File: app\etc\modules\Namespace_Module.xml
<config>
<modules>
<Namespace_Module>
<active>true</active>
<codePool>community</codePool>
</Namespace_Module>
<Mage_Cms>
<depends>Namespace_Module</depends>
</Mage_Cms>
<Mage_Customer>
<depends>Namespace_Module</depends>
</Mage_Customer>
</modules>
</config>
Here we make our module as a dependency for the core modules Mage_Cms
and Mage_Customer
. This will force our module's observer to listen very first.
I hope this will make sense now. Let me know if you have any further doubts.
1 : Module dependency is a technique which is used in Magento for ordering loading of modules based on the dependency specified in the activation files (XML files which we can find inside app/etc/modules/
)