Create Own Module in Magento – Part -1

How to create Custom module in magento:
Now am going to create my custom module with folder structure (only structure not entire code) in magento. Module contain one Mysql Table. This module you can use it in Community folder. Also same module you can use it in any of the other magento product. Just you have to installed this files thats it. The module will be active in admin. This post will helpful to, how to create or develop our own custom module in magento. Also how to use our first mysql install table in magento.
Here am just declare the table structure and folder structure based on your requirement you can modify.
My Package Name is : Jute
My Module Name is Travelinfo
Folder Structure is : app/code/community/Jute/ Travelinfo
Table Name is : jute_travelinfo
  1. Create etc config file:
First we have to create etc config xml file in app/etc/module folder, file is called “Jute_Travelinfo.xml
<?xml version=”1.0″?>
<config>
   <modules>
       <Jute_ Travelinfo>
           <active>true</active>
           <codePool>community</codePool>
     </Jute_ Travelinfo>
   </modules>
</config>
Yes now you module is base setup is ready. Now we have to create the folder structure as like below
  1. Folder Structure
app/code/community/Jute/ Travelinfo
Block, controllers, etc, Helper, Model, sql
In my module am going to use one admin controller & Mysql Install file & Block, Helper, Model, so that i have declared my config file as like below
Jute/Travelinfo/etc/config.xml
<?xml version=”1.0″?>
<config>
   <modules>
       <Jute_Travelinfo>
           <version>0.1.0</version>
       </Jute_Travelinfo>
   </modules>
   <global>
              <blocks>
           <jute_travelinfo>
               <class>Jute_Travelinfo_Block</class>
           </jute_travelinfo>
       </blocks>
       <helpers>
           <jute_travelinfo>
               <class>Jute_Travelinfo_Helper</class>
           </jute_travelinfo>
       </helpers>
            <models>
           <travelinfo>
               <class>Jute_Travelinfo_Model</class>
               <resourceModel>travelinfo_mysql4</resourceModel>
           </travelinfo>
           <travelinfo_mysql4>
               <class>Jute_Travelinfo_Model_Mysql4</class>
               <entities>
                   <travelinfo>
                       <table>jute_travelinfo</table>
                   </travelinfo>              
               </entities>
           </travelinfo_mysql4>
       </models>
 
       <resources>
           <travelinfo_setup>
               <setup>
                   <module>Jute_Travelinfo</module>
               </setup>
               <connection>
                   <use>core_setup</use>
               </connection>                         
           </travelinfo_setup>
            <travelinfo_read>
               <connection>
                   <use>core_read</use>
               </connection>
           </travelinfo_read>          
 
           <travelinfo_write>
               <connection>
                   <use>core_write</use>
               </connection>
           </travelinfo_write>        
       </resources>        
   </global>
   <admin>
       <routers>
           <adminhtml>
               <args>
                   <modules>
                       <jute_travelinfo before=”Mage_Adminhtml”>Jute_Travelinfo_Adminhtml</jute_travelinfo>
                   </modules>
               </args>
           </adminhtml>
       </routers>
   </admin>
</config>
Red color mentioned code above is useful for declare or defined my table in config file.
Green color code will helpful to read & write the data from DB.
Create Helper Class:
class Jute_Travelinfo_Helper_Data extends Mage_Core_Helper_Abstract
{
}

 

Part-1 Continue…..to next Post

Leave a Reply