How to Register a New Module in Magento 1.x

Published Nov 03, 2015Last updated Nov 05, 2015
How to Register a New Module in Magento 1.x

In order to register a new module in Magento 1.x, you need to create 2 files. One is a module registration file. The other is a configuration file.

Module Registration

First, place a new file inside of app/etc/modules/.

Name this file according to your Vendor name / namespace and module name. For example, if I was creating a blog module, I would use the file name: Coolryan_Blog.xml.

So, here we would create the file: app/etc/modules/Coolryan_Blog.xml.

The contents of the file look like this:

<?xml version="1.0"?>

<config>

    <modules>

        <Coolryan_Blog>

            <active>true</active>

            <codePool>local</codePool>

        </Coolryan_Blog>

    </modules>

</config>

<config> - the top level node for all configuration files.

<modules> - where module declaration information belongs.

<Coolryan_Blog> - Your module identification node. Magento will try to resolve folder names based on this node.

<active> - true or false.

<codePool> - Which code pool this module belongs in. There are three code pools, (core, community, and local). Your code should always belong inside of local or community. NEVER core! NOTE: There is a capital "P" in the `` node. Your module will not work without that capital "P"!

Configuration

Now, you need to create your module folder structure to match your nodes in the module registration file. So, in this example, it will look like app/code/local/Coolryan/Blog/etc. Inside of the etc/ folder, you need to create a new file called config.xml.

Your config file holds all kinds of information pertaining to your module, but we will start simple. We will just create a version number for our module.

Inside of config.xml:

<?xml version="1.0"?>

<config>

    <modules>

        <Coolryan_Blog>

            <version>1.0.0</version>

        </Coolryan_Blog>

    </modules>

</config>

This looks much like the previous file. Now, all we are specifying is our version, inside of a <version> node.

Now, clear your cache inside of Magento and your new module should be visible to Magento!

Troubleshooting

To check to see if your module shows up, check your admin panel under System -> Configuration -> Advanced -> Advanced. You should see a list of all modules registered in your system.

If it does not show up:

  1. Clear or disable your cache.
  2. Enable Developer mode and break your configuration files by creating invalid markup, (to see if they are being loaded by Magento).
  3. Check folder names and node names. (Does <Coolryan_Blog> match app/code/local/Coolryan/Blog/?)
  4. Check node nesting and node naming. Case matters!
  5. Check file and folder naming. Case matters!
  6. Do your code pools match? (local matching app/code/local/Coolryan/Blog?)

Now you can start developing for Magento!

Discover and read more posts from Ryan Street
get started
Enjoy this post?

Leave a like and comment for Ryan

1