Basics to create a custom module in magento

1. How to create a module

MODULE NAMESPACE

The first directory we will create is a “namespace.” This can be called anything you like, but the convention is some form of the name of the company or module’s author.
So, create the directory app/code/local/[namespace]

MODULE NAME
Create the directory app/code/local/[namespace]/[module name].
Module name should be according to functionality of our module.
We should now have the following directory structure for our module. These directory and file names are case-sensitive, so capitalize where appropriate.


app
  - code
      - local
          - [namespace]
              - [modulename]

2. Configure our module

Next, we will begin to configure our module. The configuration files belong inside our module in a directory named etc.
app/code/local/[namespace]/[modulename]/etc/config.xml.
Now, we will create a simple config.xml file, which contains following code:

<?xml version="1.0" encoding="UTF-8"?>
	
	<!-- The root node for Magento module configuration -->
	<config> 
	 
	    <!-- 
	        The module's node contains basic 
	        information about each Magento module
	    -->
	    <modules>
	 
	        <!--
	            This must exactly match the namespace and module's folder
	            names, with directory separators replaced by underscores
	        -->
	        <namespace_modulename>
	 
	            <!-- The version of our module, starting at 0.0.1 -->
	            <version>0.0.1</version>
	 
	        </ namespace_modulename >
	 
	    </modules>
	 
	</config>

3. Activating Our Module

The next step is to inform our Magneto installation that our module exists, which we do by creating a new XML file in app/etc/modules.
The name of this XML file can be anything you like but it is preferable that we use like below
Let’s create app/etc/modules/[namespace_modulename].xml with the following content:

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <namespace_modulename>

            <!-- Whether our module is active: true or false -->
            <active>true</active>

            <!-- Which code pool to use: core, community or local -->
            <codePool>local</codePool>

        </namespace_modulename>
    </modules>
</config>

Speak Your Mind

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: