Today we will go through some basics points for Magento Development.
When any developer starts working with Magento he must know about what is Codepools and How does Magento interacts with Codepools.
1) Magento Codepools:
Magento has three different codepools:
Community : app/code/community/
Core : app/code/core/
All existing feature of Magento code exists in this folder. The best practice that Magento team suggest not to change any code in core files only Magento Team can make changes in that in New releases. So that it will not create problem in time of Magento Upgradation from old version to the new one.
In this folder we will have all the 3rd party extension. Basically, all extensions that we install from Magento Connect that will be found in app/code/community/
This code pools also for community developers as well as store owners who want to make their work by their own. If you want to enhance any core functionality or make any changes in core files you can change it in this code pools at the time of up-gradation your change not be overwritten or removed.
In any Magento Extension we need to define code pools, so that Magento can understand where to find files for that extension.
Example: app/etc/modules :
<?xml version="1.0"?> <config> <modules> <Mementia_LookBook> <active>true</active> <codePool>local</codePool> </Mementia_LookBook> </modules> </config>
How does the Magento interact with the various code pools?
To check that process have 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.
Another important point to understand are templates and layouts.
2) Magento templates and layout files location :
A theme consists of the following elements:
- app > design > frontend > package_name(Base) > theme_name(Default) > layout
- This folder includes XML files that define the layout of the theme. Layout files are basically a key part of view for MVC. This detects which block to load and which template files to be loaded in which controller action.
Because of Magento modularity, all XML files of the default theme are stored in separate folders with the name of the module to which they belong to. A non-default theme, vice-versa, should have a single layout file, named local.xml, where all layout updates are placed.
- app > design > frontend > package_name(Base) > theme_name(Default) > template
- This folder contains of .phtml files that have HTML and PHP code for each Magento blocks which will be displayed in the frontend.
- app > design > frontend > package_name(Base) > theme_name(Default) > locale
- This folder contains .of CSV files organized on a per language basis that provide translations in format of languagecode_COUNTRTYCODE (en_US or en_UK)/translate.csv.
skin > frontend > package_name(Base) > theme_name(default) > css : Which has css files means to style look and feel of our theme.
skin > frontend > package_name(Base) > theme_name(default) > images : Which has image files used for our theme.
These were some basic points that we need to understand before we start the actual Magento development.