Creating Simple Extension

To create a simple extension for a Magento 1.9 or less website, follow these simple steps.

Step 1 Create a XML file inside root folder/app/etc/modules/Your Company Name_Your Extension Name.xml. For example C:\Program Files\Xampp\htdocs\magento\app\etc\modules\Mohan_Simple.xml or /var/www/html/magento/app/etc/modules/Mohan_Simple.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Mohan_Simple>
            <active>true</active>
            <codePool>local</codePool>
        </Mohan_SImple>
    </modules>
</config>

 

Step 2 Create a folder inside root folder/app/code/local/Your Company Name/Your Extension Name For example C:\Program Files\Xampp\htdocs\magento\app\code\local\Mohan\Simple or /var/www/html/magento/app/code/local/Mohan/Simple

This is your extension folder inside this folder you have to create a etc folder and a config.xml file with a code like below.

<?xml version="1.0"?>
<config>
    <modules>
        <Mohan_Simple>
            <version>0.1.0</version>
        </Mohan_Simple>
    </modules>    
    <frontend>
        <routers>
            <Mohan_Simple>
                <use>standard</use>
                <args>
                    <module>Mohan_Simple</module>
                    <frontName>simple-extension</frontName>
                </args>
            </Mohan_Simple>
        </routers>
    </frontend>    
</config>

 

Step 3 Finally create a controller for your simple extension inside root folder/app/code/local/Your Company Name/Your Extension Name/controllers/IndexController.php For example C:\Program Files\Xampp\htdocs\magento\app\code\local\Mohan\Simple\controllers\IndexController.php or /var/www/html/magento/app/code/local/Mohan/Simple/controllers/IndexController.php

with a sample code as given below

<?php
class Mohan_Simple_IndexController extends Mage_Core_Controller_Front_Action
{
    public function indexAction()
    {
        echo 'My Simple Extension';
    }
}
?>

 

Now you can see the out put as “My Simple Extension” when you open the URL http://yourdomain/simple-extension for example http://localhost/magento/simple-extension or http://magentosite.com/simple-extension.

Complete extension will look like this Mohan_Simple. Download and paste this in your magento installation for quick use.

Tags:
One Comment

Add a Comment

Your email address will not be published. Required fields are marked *