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.
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.
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>
Chandra Shekhar
Latest posts by Chandra Shekhar (see all)
- Best practices for micro service design - January 23, 2022
- Spring Boot - January 23, 2022
- Java - January 23, 2022
Recent Comments