Describe Magento codepools

What is Magento codePool:

Magento is a well structured E-Commerce software system. Which follows a good architecture that not only gives best features for their users but a good way to organize magento modules .

 

 

Purpose of Magento CodePool:

The magento modules are well organized by codepools.So basically codepool is a folder structure (folder based basket) where we keep our modules in well organised way.

 

Example: Suppose you have to collect and put all apples one side, all banana’s in one side and all orrange in one side then you can choose three baskets one for apples, one for banana and one for orrange.

Similarly, Magento has three folders which are used to keep all modules of magento that are required for running your application.

magneo_codepool

Types of CodePool in Magento:

There are 3 codepools in magento

i) Local

ii) Community

iii) Core

magento_codepool.png

 

i) Purpose of Local Code Pool in Magento:

If we need to override any existing module just for the purpose of our application level customization then we need to use these local code pool . In other words all the modules that are created for the purpose of either override to core controller or created by own  then such modules will be resides under this codepool.

magento_structure

 

ii) Purpose of Community Code Pool in Magento:

This code pool contains all the modules which are created by third parties. This Code Pool is entirely dedicated to community developers and this is the best place to have all 3rdh party magento extensions.Which are downloaded from magentocommerce.com (either free or paid). This is theoretically good but you might see several modules that goes to local code pool even you have installed if from magento commerce. This is becaused the developer has not followed proper codepool before deploying the extension. Although this wouldn’t create any issue on magento.

 

 

iii) Purpose of Core Code Pool in Magento:

Core Code Pool is the most lower (as the name suggest its core) code pool. It  contain all core modules of magento so during development cycle we shouldn’t make any changes from our side otherwise it might be harmfull for your sites’s health in long run. Even if you require to do such things you might override the controllers under local codepool and make whatever changes you need to do for that.

 

How does these modules interact each other:

 

Under app/mage.php file you might see their calling


/**
* Set include path
*/
$paths = array();
$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'));

 

 

You can see magento set these code pools under include path. And You can also notice their ordering . Code Pool orderings are

 

 

i) local

ii) community

iii) core

 

it means if some file to be included then first of all magento looks for same under local code pool. If its not found there then second attempt magento looks under community code pool. IF even there the file is not there then magento finnally use core code pool and get file from there.

 

How to check which codepool is being used for each module:

You can go to app/etc/module/namespace_modulename.xml file

You will see code like


<?xml version="1.0" encoding="UTF-8"?>

<config>

<modules>

<Flagbit_Faq>

<active>true</active>

<codePool>community</codePool>

</Flagbit_Faq>

</modules>

</config>

The following two tabs change content below.

Chandra Shekhar

GCP Architect
Chandra Shekhar Pandey is Google certified Cloud engineer, I am Magento2 Trained developer. Having huge experience in designing cloud solution. I have around 12 years of experience with world enterprise IT companies and fortune 500 clients. During my architecture design I am always caring about high availability, fast performance and resilient system. From the programmer background I have huge experience in LAMP stack as well. Throughout my carrier I have worked on Retail, E-Learning, Video Conferencing and social media domain. The motive of creating cutehits was just to share the knowledge/solutions I get to know during my day to day life so that if possible I can help someone for same problems/solutions. CuteHits.com is a really a very effort for sharing knowledge to rest of the world. For any query/suggestion about same you can contact me on below details:- Email: shekharmca2005 at gmail.com Phone: +91-9560201363

Latest posts by Chandra Shekhar (see all)

You may also like...