Some basic points for Magento Development | Mementia

Some basic points for Magento Development

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/

Local :app/code/local/

Core pool

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.

Community pool

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/

Local pool

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.

app/code/local/

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:

Layout :

- 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.

Template :

- 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.

Locale :

- 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.

We should know where skin and Javascript will be located and what is purpose of that.

3) Magento skin and javascript files location

Skin :

This folder includes CSS ,Javascript and image files that are used in .phtml files in template folder, Note: This folders files can be different per theme basis.

skin > frontend > package_name(Base) > theme_name(default) > js : Which has javascript files

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.

JS :

This folder embodies JS files, libraries and frameworks that are used via frontend and backend. If you need to add a new Javascript/AJAX library or your module from Local code pool requires special scripts, they should be placed here.

These were some basic points that we need to understand before we start the actual Magento development.

Share this post