Magento codepools

Magento-Logo

Magento has three different codepools:

Community
Core
Local

code2

Core pool

This core pool 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 the core pool.

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. 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 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 snippet illustrates the order Magento is using to include paths – firstly it includes Local code pool, than community and after that – core, which allow developers to override classes without changing core files.

How to Call Static Block from CMS Pages in Magento

Magento-Logo

I have come to many situation to call static block from CMS Pages, and i am using the below code to do this trick. You can use this code to call a static block on any of your CMS page like homepage so you just follow the steps
Go To CMS->Pages
Select Your page

Go To Design->Layout Update XML
Reference means the block will call on left right or Content



static-block-identifier

In case if reference already there then just use

static-block-identifier

Enjoy πŸ™‚

How to display a menu with categories, sub-categories in Magento

magento-logo

If you need to display a custom menu based on your categories, subcategories in magento, you can use the below code for the same.

<?php $_helper = Mage::helper('catalog/category') ?>
<?php $_categories = $_helper->getStoreCategories() ?>
<?php $currentCategory = Mage::registry('current_category') ?>
<?php if (count($_categories) > 0): ?>
    <ul>
        <?php foreach($_categories as $_category): ?>
            <li>
                <a href="<?php echo $_helper->getCategoryUrl($_category) ?>">
                    <?php echo $_category->getName() ?>
                </a>
                <?php $_category = Mage::getModel('catalog/category')->load($_category->getId()) ?>
                <?php $_subcategories = $_category->getChildrenCategories() ?>
                <?php if (count($_subcategories) > 0): ?>
                    <ul>
                        <?php foreach($_subcategories as $_subcategory): ?>
                            <li>
                                <a href="<?php echo $_helper->getCategoryUrl($_subcategory) ?>">
                                    <?php echo $_subcategory->getName() ?>
                                </a>
                            </li>
                        <?php endforeach; ?>
                    </ul>
                <?php endif; ?>
            </li>
        <?php endforeach; ?>
    </ul>
<?php endif; ?>

‘The directory is not writable by server’ error in Magento

directory-is-not-writable-error

If you are facing an error ‘The directory is not writable by server’ in magento please ensure the following :

First of all Check if the server has the write permission on var and media folders. This might solve the issue. If still the issue persists go through the following steps:

check whether the ‘media/catalog’, ‘media/wysiwyg’ and ‘media/images’ are there in the media folder. If it doesn’t exists create the folders, and give write permisission for those folders.

Hope this will resolve your issue.