The Basics of Creating a Magento Module

A lot of Magento community provides a variety of feature rich modules (free or paid).Together with the magento functionality, it allows you to solve a lot of tasks without programming skills. But what if they don’t work as you want them to? So it’s better to create your own module from scratch and understand the Magento architecture as well.

Creating a custom magento module is a core part of any magento project. Because at any point, you may need to integrate your own functionality in your existing magento project.

This article will cover a number of interesting topic :

· The app/code directories

· The structure and creation of a Magento module

· Event observers

Before we begin install Magento, either locally or on a development server


You can do this by going to Admin Panel > System > Cache Management > Select All > Actions: Disable > Submit.

The app/code Directory

app/code directory is split into three areas: core, community and local.


The app/code/core directory contains all of the functionality regarding products, categories, customers, payments, etc.


app/code/community contain modules that have been provided by third parties


An empty app/code/local directory. Here we can add modules for our magento installation.


Create is a “namespace.

Create the directory app/code/local/iMediadesigns


The module we are creating will write log entries each time a product is saved, Create the directoryapp/code/local/iMediadesigns/LogProductUpdate.

Configuring Our Module

Create a simple config.xml file

<?xml version=”1.0" encoding=”UTF-8"?>

<! — The root node for Magento module configuration →


<! —

The module’s node contains basic

information about each Magento module


<! —

This must exactly match the namespace and module’s folder

names, with directory separators replaced by underscores


<! — The version of our module, starting at 0.0.1 →





Activating Our Module

Let’s createapp/etc/modules/iMediadesigns_LogProductUpdate.xml with the following content:

<?xml version=”1.0" encoding=”UTF-8"?>




<! — Whether our module is active: true or false →


<! — Which code pool to use: core, community or local →





Is The Module Enabled?

Navigate to System > Configuration > Advanced > Advanced and view the “Disable Modules Output” listing, we should see our iMediadesigns_LogProductUpdate module listed as enabled.

Configuring Our Model’s Directory

We need to inform Magento where to find models in our module by updating config.xml

<?xml version=”1.0" encoding=”UTF-8"?>







<! — Configure our module’s behavior in the global scope →


<! — Defining models →


<! —

Unique identifier in the model’s node.

By convention, we put the module’s name in lowercase.


<! —

The path to our models directory, with directory separators replaced by underscores →<class>iMediadesigns_LogProductUpdate_Model</class></iMediadesigns_logproductupdate>














Admin Panel > System > Configuration > Developer > Log Settings > Enabled.

The article will help you to understand how magento module works and to make your magento web development project successful. If you have any questions let us know in the comments section.

iMediadesigns provide cost effective web design and development solutions and offers custom website design services in Toronto