Get Free Audit

Module Initialization in Magento 1

Nov 21, 2017

987 Andrey Litvin

Module Initialization in Magento 1

If you’re going to take the Magento exam, the article seems rather useful for you, as it is dedicated to one of the most topical issues. Module initialization in Magento 1 covers such questions as module definition, the process of module initialization including module declarations and config files. The step-by-step guide is assured to be indispensable for you.

Module definition

In order to create a new module in Magento 1, we need to create two config files which describe the module and its dependencies in Magento.

The first config file we’re creating is app/etc/modules/Vandor_Module.xml:


Where the tag <active> is a status definition of the module and the tag <codePool> describes which folder will be used by the module. The block <depends> describes module’s dependencies on other modules.

The second config file is app/code/local/Vendor/Module/etc/config.xml:


Here we can define the module version and additionally declare the module’s block, controllers or other resources.

Module initialization process

If you want to understand how modules are loaded in Magento 1, we need to consider the method \Mage_Core_Model_App::_initModules.


This method checks if the modules can be loaded from cache and in case if it can’t be performed, it starts loading modules from declaration and configuration files by calling the method \Mage_Core_Model_Config::loadModules.


The method \Mage_Core_Model_Config::loadModules consists of two main steps:

  1. loading module declarations
  2. loading module config files

Loading module declarations

Module declarations are loaded via the method \Mage_Core_Model_Config::_loadDeclaredModules:

Andrey_Dubina
Partner With Us Let's discuss how to grow your business. Get a Free Quote.
Talk to Andrey


This method iterates through app/etc/modules directory and loads XML files located there. The first file to load is always Mage_All.xml which contains essential core modules of Magento 1. The files the names of which start with Mage_ are loaded just after Mage_All.xml. These modules are considered as a part of Magento core, but they depend on the modules from Mage_All.xml and should be loaded after that. The rest of the list contains a third party community and local modules.

Modules can have dependencies on other modules which are declared in .xml files.

The dependent modules need to be loaded after the dependencies and in order to perform it, the module list should be sorted out. The process takes place in \Mage_Core_Model_Config::_sortModuleDepends method.

Loading module config files

Config files are loaded in the method \Mage_Core_Model_Config::loadModulesConfiguration:


This method checks if configuration settings allow using the local modules. Then it iterates through all declared modules and loads config.xml from the module directory if the module is enabled. In order to prevent settings overwriting from etc/local.xml (they should be loaded last), Magento loads configurations from the first file once again.

The last step in module initialization is saving collected data into the cache. Using cache speeds up subsequent call, as Magento can skip this entire process by reading the module configuration that has already been loaded and processed from the cache.

Andrey Dubina
Partner With Us Looking for a partner to grow your business? We are the right company to bring your webstore to success. Talk to Andrey

Post a new comment

BelVG Newsletter
Subscribe to our mailing list and get interesting stuff and updates to your email inbox.
Email *