4

Is there a way to ensure that a module and its config xml is loaded last in Magento, or at least after a specific other module?

I want to avoid using the <depends> tag because it may not be 100% that the module i want my configuration loaded after will be installed.

2 Answers 2

12

From what I am reading, the only way to do this is by the depends tag, even if you made your module name ZZZ... The module list is re-ordered after being fetched based on dependencies...

The function Mage_Core_Model_Config::_loadDeclaredModules scans the directory etc/modules and loads XML files located there. These files contain module declarations. Before loading their contents, the system arranges them into a specific order. The first file in this list is Mage_All.xml. The modules declared in this file comprise the essential core functionality of Magento. Next in line are the declaration files whose names begin with Mage_. The modules declared there are a part of the Magento core as well, but often depend on the modules from the Mage_All.xml file and thus must be loaded after those. The rest of the list are declarations of third party modules: community modules and your local extensions. Once the list is compiled, Magento fetches the files in the order they are listed and loads their contents into an object of type Mage_Core_Model_Config_Base – the application configuration object, which Magento queries whenever a configuration entry is requested. The loaded configuration must be ordered once more – this time according to module dependencies.

0

Though Jeffrey L. Roberts' answer is Magento-1 specific in details, the same answer applies for Magento 2. Without declaring a dependency (in the <sequence> element), one cannot alter the order of Modules' loading in Magento 1 or Magento 2.

One would have to address the specific reason for ensuring that their module is loaded after another module on a case-by-case basis. Th PHP function class_exists() is often useful for this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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