Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to Create Magento Custom Admin Module

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 108
    Comment on it

    In this blog tutorial, i am going to explain how to create magento custom admin module in backend admin panel.
    Lets start by creating the following folders:
    app/code/local/My/Pant/etc
    app/code/local/My/Pant/controllers
    app/code/local/My/Pant/Helper

    1. create a file config.xml in etc folder of custom module and paste in the following code:

    <?xml version="1.0"?>
    <config>
        <modules>
            <my_pant>
                <version>1.0.0</version>
            </my_pant>
        </modules>
        <global>
            <models/>
            <blocks/>
            <resources/>
            <extraconfig/>
            <helpers>
                <pant>
                    <class>My_Pant_Helper</class>  //path of helper files
                </pant>
            </helpers>
        </global>
        <admin>
            <routers>
                <pant>
                    <use>admin</use>
                    <args>
                        <module>My_Pant</module>
                        <frontName>pant</frontName>  
                    </args>
                </pant>
            </routers>
        </admin>
    </config>

    <frontName>pant</frontName> //This is the URL  of the module. i.e www.yourstorename.com/index.php/pant will be the url of your module.

    2. Now, create a file called adminhtml.xml within the same folder and paste in the following:

    <?xml version="1.0" ?>
    <config>
        <menu>
            <my_menu translate="title" module="pant">
                <title>Pankaj Pant</title>
                <sort_order>1</sort_order>
                <action>pant/index/index</action>
            </my_menu>
        </menu>
    </config>

    3. Next step is to tell Magento to load our module , To do this we need to create a file My_Pant.xml in /app/etc/modules and paste in the following:

    <?xml version="1.0"?>
    <config>
        <modules>
            <My_Pant>
                <active>true</active>    //  is active or not
                <codePool>local</codePool> //location of the module i.e inside the local folder
            </My_Pant>
        </modules>
    </config>

    4. create a file called Data.php with the Helper folder (/app/code/local/My/Pant/ Helper/ Data.php). & Paste the following code in Data.php

    <?php
    class My_Pant_Helper_Data extends Mage_Core_Helper_Abstract
    {}
    ?>

    Last step 5. create ‘IndexController.php’ file in  dir -> /app/ code/local/My/Pant/controllers/ ) and Paste the following code.

    <?php
    class My_Pant_IndexController extends Mage_Adminhtml_Controller_Action
    {  
        public function indexAction()
        {
            $this->loadLayout();
             
            $block = $this->getLayout()->createBlock('core/text', 'My-block')->setText('<h1>hello</h1>');
            $this->_addContent($block);
             
            $this->_setActiveMenu('my_menu')->renderLayout();      
        }   
    }
    ?>

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: