Tuesday, August 5, 2014

Code pool in Magento


Magento has three different codepools:

  1. Community
  2. Core
  3. Local

Core pool


First of all, this folder stores all the code that makes Magento so powerful, flexible and lovely. The chief rule of Magento development is that you should never make any changes in it. In other words, this folder belongs to Magento core developers only and if you are going to edit anything in this pool, their evil spirit could punish you even through the display.

Community pool


This folder belongs entirely to community developers. This is the right place for hundreds of 3rd party extensions, both free and paid, that can be found at MagentoConnect or available on extensions development store. So basically, if you have installed any extension, it must be in app/code/community/ only.

Local pool


If you have your own Magento-based store and want to make everything by yourself or you are a Magento developer and have a purpose to change the logic somehow, local pool is the place where everything should be done. If you want to override Magento extensions, blocks or methods, copy the necessary folders from the Core pool and do whatever you are inclined to do. Apply the same rule for custom extensions that are created specifically for the website – all code should be in local pool.

How the framework knows which code pools apply in particular module

Please look in app/etc/modules and open any of custom module file

<?xml version=”1.0″?>

<config>

<modules>

<Custom_Module_Name>

<active>true</active>

<codePool>local</codePool>

</ Custom_Module_Name>

</modules>

</config>

Here you can see line of in this custom module return local so Magento search this module in local code pools. Exactly like this if you check any core functionality module here we take example of Mage_ImportExport.xml here I saw you code snippets of this

<config>

<modules>

<Mage_ImportExport>

<active>true</active>

<codePool>core</codePool>

<depends>

<Mage_Catalog/>

</depends>

</Mage_ImportExport>

</modules>

</config>

Here you can see code pool is core.

How does the framework interact with the various codepools?

To identify the proccess let’s take a look at app/Mage.php

$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';

Can We give the Code Pool Outside the “code” Directory in Magento ?

You can have your custom codepool by putting below line in your app/Mage.php

$paths[] = BP . DS . 'app' . DS . 'code' . DS . 'custom';

What to Do if you wanted to create Custom codepool outside core directory ?

if you want to keep your codepool in app/custom then creating symlink for your codepool will be the easiest way. Infect you can place your codepool anywhere in your system.

This is how you will create your symlink(considering /home/ashok/public_html is your magento root directory)

ln -s /home/ashok/public_html/app/custom/custom/ /home/ashok /public_html/app/code/custom

A blogger

I am passionate blogger cum B.Tech. Computer engineering graduate. I love writing blog post. I spend my free time in writing blog post that will useful to everyone (including me). I have had some success making money blogging and want to help others do the same. I just figured that by creating a great and free resource a lot of links would follow – and they have. Some people ask me how they can repay me – which is not necessary - but for those wanting to show their appreciation, I just say linking to the article from their blog is the best compensation I could receive. Thanks for reading!

0 comments:

Post a Comment

Thanks for commenting. I will Reply you soon

 

Copyright @ 2013 PHP WORDPRESS MAGENTO .

Designed by Kcon Technosoft