ECommerce Insights Blog

Stay on top of it all and get ahead with useful articles, how-tos, tips and tricks on e-commerce.

How To Customize The Magento Core Without Actually Changing It

Multi Purpose Homepage with Multiple Layouts & Mega Menu

Magento Core - How to override Magento core

There might be some particular reasons when you have to change the Magento‘s core files then you should be very careful otherwise all your changes made in core files will be lost when the current Magento version is upgraded to latest version. Before changing anything in the core you should device a clear cut policy to ensure that your customized core files are upgradable, non-over writable and easier to accommodate further customizations.

Magento gives the flexibility to customize it’s core but the most important thing is the developers discipline. A slight negligence can make all efforts go in vain especially when the Magento version is upgraded, degraded etc.

Understanding Magento’s Configuration Files

Magento uses merging concept of several files (XML) into one global cached configuration file (XML) just to achieve maximum flexibility of configuration without need for manual editing of configuration files.
Notice how 2 configuration XML files are merged into one global configuration file

Sample 1 (Configuration)


Sample 2 (Configuration)


Merged file contains both the sample configuration files.


Important Files Used In Magento Configuration

Refer init() method under app/code/core/Mage/Core/Model/Config.php

  1. If usage of config cache is enabled, Magento will try to load the configuration from cache. If loaded successfully, it will skip all the following steps.
  2. Load app/etc/config.xml. This file contains values absolutely necessary for successful load of Magento core components.
  3. Merge all files from app/etc/modules/ (app/etc/modules.xml until 0.6.14100). Files containing modules declarations are dropped here by the core, community and custom packages installed, and are named by package name (Mage_All.xml).
  4. Merge app/etc/local.xml. Contains settings for local database connections, installation date and local encryption key.
  5. If app/etc/local.xml was not found (not installed yet) app/etc/distro.xml is merged. Contains auto-configured values to be used in installation wizard.
  6. Merge config.xml from all the modules that were declared in app/etc/modules/*. These are: app/code/{codePool}/{companyName}/{moduleName}/etc/config.xml


Models are basically set of specific classes to define abstract or resource specific logic. Following code will display how to define a new module functionality:

Lets’ create app/etc/modules/Example_Module.xml:


Now lets create app/code/local/Example/Module/etc/config.xml:


The above code will enable us to use $obj = Mage::getModel('example_mod/test_model') and will return an instance of the class Example_Module_Model_Test_Model, located under app/code/local/Example/Module/Model/Test/Model.php. Notice how example_mod is replaced with Example_Module_Model and together with test_model generate name of required class.

Further Reading: How to Override Magento’s Core Model Classes


The real beauty lies under customization especially if you are willing to upgrade the code without changing the files manually. Now, if the discipline is followed you can easily override the functionalities without actually changing the core files.

Now, lets take an example where we will try to create a new module In our example we will create a new module called Example_Custom which will further override the Example_Module functionality. Defining this new module is same as app/etc/modules/Example_Module.xml


To ensure that the application won’t break we will provide all classes in our custom module that exists in our original module.


Now lets override only one class to see how it works


now our app/code/local/Example/Custom/Model/Test/Model.php will look something like this:

Now, everywhere in the code $obj = Mage::getModel('example_mod/test_model') will return an instance of Example_Custom_Model_Test_Model with all original functionality of Example_Module_Model_Test_Model and custom exampleMethod.


Helper are the support classes for performing some specific manipulations with data in *.phtml templates or in *.xml layouts i.e.

$this->helper('wishlist'); // wishlist module; data.php helper
$this->helper('catalog/image'); //catalog module; image.php helper
$this->helper(); //current module; data.php helper

Helpers are also useful for caching purposes (refer to core/Mage/Core/Helper/Abstract.php)


Resources are overloaded the same way as we overload models. These are the data persistence resources used by the system’s data mapper. Also business logic for model collections are encapsulated in collection resources. All data access funnels down thru the resources from the models (or controllers, if business logic is being defined in a page controller )

Admin Menu and ACL

Admin menu is setup in app/code/core/Mage/Adminhtml/etc/config.xml Copy & paste an existing XML chunk and customize as per your requirements. You can supposedly put this in any other configuration file ( think a user created module ) & have the XML merged in.

Magento Customization How To's

I am still drafting my howto's for customizing Magento. Just, stay tuned for my next post where i will focus on how to customize Blocks, Controllers and Themes.

Please leave me a comment and let me know your own experiences of Overriding the Magento core. Subscribe our RSS to receive latest Magento updates.