Magento 1 Code Pools


If you are just learning Magento 1, there are few else that you need to start with other than the code pools and how to interact with the code.  Remember, never modify the core!

Magento has three different codepools to chose from in the code structure (app/code/..):

  • Community
  • Core
  • Local

Magento 1 code pools

The Core Code Pool

The core code pool is the sacred cow of Magento 1.  This folder stores all the code that makes Magento so powerful, flexible and extensible. The golden rule of Magento development is that you should never (I repeat never) make any changes in it. In simple words, this folder belongs to Magento core developers only.  If you want to modify something here you should always get verification from Magento themselves.   About .01% of the time I have seen that core mods are needed to complete a task but this should never be one of your first 5 options.

The Community Code Pool

The community code pool belongs  to community developers and professional extension agencies. This folder is where you will find hundreds of 3rd party extensions, both free and paid extensions that developers list on MagentoConnect or on their own extension development stores. In short, if you have installed any extension from the Connect store, it must be in app/code/community/ only.  This allows you access to upgrade extensions easily and you’ll know where to look.

The Local Code Pool

The local code pool is for where you (as a developer) or if you are a Magento retailer you will utilize the Local Code Pool to make overwrites of extensions or core code.  If you are a Magento developer and have a need to change the code logic somehow this local code pool is the place where everything should be done.  It is the safest and most easy place to make modifications.  Magento reads the local code pool first, so your changes will be read and if there are none then Magento goes to the Community pool and reads the code. If you want to override Magento extensions copy the necessary folders and files from the Core pool and do whatever you need to do to finish your work. Apply the same rule for custom extensions that are created specifically for the website – all code should be in local pool.

How does the framework interact with the various codepools?

As I mentioned earlier Magento follows a certain code path.  It starts with local, then moves to community, and then reviews core.  Similar to front-end code and CSS.  The last css read on the sheet is master style.

To identify the process let’s take a look at app/Mage.php

* Set include path
$paths[] = BP . DS . ‘app’ . DS . ‘code’ . DS . ‘local’;
$paths[] = BP . DS . ‘app’ . DS . ‘code’ . DS . ‘community’;
$paths[] = BP . DS . ‘app’ . DS . ‘code’ . DS . ‘core’;
$paths[] = BP . DS . ‘lib’;
$appPath = implode(PS, $paths);
set_include_path($appPath . PS . Mage::registry(‘original_include_path’));
include_once “Mage/Core/functions.php”;
include_once “Varien/Autoload.php”;