Magento – Magento ensure module config is loaded last

configurationmodule

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.

Best Answer

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.

Related Topic