Covering The Steps of Magento Module Development

Covering The Steps of Magento Module Development

0 29600
Magento Module Development

Magento connect. Modules are an integral part of Magento. These nifty little tools play an important role in solving a variety of tasks within the Magento platform with minimal efforts. Custom module development empowers online retailers in providing a rich and engaging shopping experience to their visitors by leveraging the benefits of advanced features in Magento.

Developing a custom module provides outstanding flexibility to design an effective e-commerce solution based on specific business requirements. When combined with the excellence of Magento, these custom modules make it easy for the online players to perfect tasks based on specific functionalities that are absolutely unique to their business. This way they are more equipped to discover the power of Magento and implement customized solutions that are fit to their needs.

In this post, we are going to discuss about the ways through which we can easily develop custom modules and thus extend the abilities of our online store. But first understand the basic structure of Magento.

There are basically three kinds of Magento modules or extensions:

  1. Core – The extension is presented by default in Magento and is available in the [magentodirectory]/app/code/core/Mage folder or directory.
  2. Community – Available for free, the Community extension can be accessed from the Magento Connect website or any other community website. One can find this extension in the directory [magentodirectory]/app/code/community/[namespace]/[extensionname]
  3. Local – This extension or module is developed by third-party resources to perform some specific functions. You can find this extension in the folder or directory [magentodirectory]/app/code/local/[namespace]/[Extensionname].

Understanding The Components of Magento Modules

  • Blocks – Consist of several functions that allow you easily display data on templates.
  • Models – Business logic of modules
  • Resource Models – Contain functions that allows for database interaction
  • Controllers – Specifies page layouts and blocks and loaded when a URL is requested by the user.
  • Etc – Consists of configuration files in XML formats. It informs Magento about the number of modules and how they are going to interact.
  • Helpers -functions that help you define business logics. These functions can be used anywhere across the Magento.
  • SQL – integrates SQL scripts to help you create and modify SQL tables.

Assigning Name to Your Module

First of all, we need to give an appropriate name to our module. Generally, the name of Magento modules are made of two parts: <Namespace>_<Module>. One of the most practical ways of assigning name to Magento module is to select <Namespace>, wherein you can either add author name or company name and in <module> you can add the actual module name.

So, on the basis of above mentioned conditions, we are assigning name to our module as xyz_myMagentomodule. This name will be used as a reference in the entire article.

Creating Directories and Configuring Them

Here, we need to set up directories on the basis of what we have mentioned above. For this, simply navigate to your Magento installation direction and then go to app/code/local and start creating directories.

Once you are done with this, it’s time to configure and activate the module that is xyz_myMagentomodule in the app/etc/modules directory. This is the directory where all the config files for Magento are stored.

<?xml version="1.0"?>

Once you run the code, Magento will start detecting the location of your module. To enable it, go to <active> tag, and specify the value ‘true’ to activate the module. If everything is going well, then you can easily locate the module in the Magento Admin Panel > System > Configuration > Advanced > Advanced > Disable Modules Output list.

Getting Started with the Development Process

Now, it’s time to create our module configuration file. This file will inform Magento about our module. For this, go to app/code/local/xyz/MyMagentomodule/etc and create a config.xml file and add the below mentioned code into it.

<?xml version="1.0"?>
            <version>0.1.0</version>    <!-- This is the version number of your module -->

Now, let’s understand the significance of each tag.

The first tag that is <module> you are noticing above contains the name and version number of your module. The version number is critical at the time of updating the module.

Next is the <frontend> tag, the tag allows you keep Magento informed about the dispatched controls. Inside this tag, we have defined <routers>, which is helpful in defining the ways for accessing multiple controls with the help of routing function.

In the tag <myMagentomodule> we have defined the name we have given to our module. The <frontend> name is used to access the frontend of the module just like name of your

The reason why we are using name of your function because this way Magento will better look for the index actions of your module’s controller file. For creating the controller file, go to app/code/local/xyz/MyMagentomodule/controllers, and add the following code into it.

class xyz_MyMagentomodule_IndexController extends Mage_Core_Controller_Front_Action {
    public function indexAction() {
        echo "Hello World";

Now, open the URL of name of your, it will display “Hello World”. Congrats! You successfully created your first Hello World Magento module.

Implementing Controller Dispatch

Now, we have to extend the class i.e., Mage_Core_Controller_Front_Action, the class consists of all the function that allows you provide a specific path to your URL. The primary function of Magento class is to define the location of class file. This way, it’s clear that Magento class reflects the location of the class file. So the class Mage_Core_Controller_Front_Action is stored in Mage > Core > Controller > Front >Action.php.

So, the class name of our controller is xyz_MyMagentomodule_IndexController. Make sure your Magento name should be defined in a way that it gives you exact (<module>tag)_(Action Controllername)(keyword Controller).

Now, let me explain you the explanation of each and every tag.

  • <module> – The name of our module i.e., xyz_myMagentomodule
  • Action <controller name> – Index
  • Action controller along with a keyword

On the basis of this pattern, the name of our controller will be:


Now, the pattern of the URL will look like this: name of your

Based on this platform, the URL for our module will be:

name of your Although you can access it using name of your because even if you don’t specify any action control or action method, Magento will still load the file by default.

Lastly, let’s create a test action

class xyz_MyMagentomodule_IndexController extends Mage_Core_Controller_Front_Action {
    public function indexAction() {
        echo "Hello World";
    public function testAction()  {
        echo "test action";

You can access the test action via

Hopefully, the tutorial has helped you in developing a custom module for Magento and implementing controlling dispatches.

Author Bio: Jason Roiz is qualified web development professional who is great at delivering focus in his writings. He meets expectations for OSSMedia, a Magento development company which also giving proficient WordPress, Drupal and Joomla and improvement administrations.



Leave a Reply