In order to go through all of these questions, the best place to start is obviously the beginning. There’s a lot of material to cover but I think by answering at least one of the questions a day I’ll be able to learn a whole lot about Magento. Piece by piece we’ll crack this bad boy open. First up in the Magento Certification Study Guide — The Basics. We need to describe the codepools in detail. Here’s the question from the guide:
Describe Magento Codepools
Magento has three different codepools:
- Community
- Core
- Local
Core
The Core Codepool is where all the magic happens; this folder contains all of the base classes where Magento gets its flexibility and functionality from. As a good rule of thumb, this folder belongs to the Core Developers only. Any functionality you need to add can generally be added by rewriting or extending the classes and their methods.
Community
This codepool belongs to all of the Community Developers and third-party modules, including those that can be downloaded from Magento Connect. Essentially if you’re installing any modules, 9 times ouf of 10 you’ll end up installing them in this codepool.
Local
Any other kind of modification, added functionality or core/community override being added to the site you’re working will end up in this codepool. If you’re making changes to just a specific site, those will end up here, too. The local codepool gets loaded first; this allows you to easily change anything instantiated in the Community or Core Codepool.
How does the framework interact with the various codepools?
To identify the proccess 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";
This code shows the order Magento is using to include code pool’s paths – First it includes Local code pool, than community and after that – core, which allow developers to override classes without changing core files.