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.
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:
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"!
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
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.
<?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!
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:
- Clear or disable your cache.
- Enable Developer mode and break your configuration files by creating invalid markup, (to see if they are being loaded by Magento).
- Check folder names and node names. (Does
- Check node nesting and node naming. Case matters!
- Check file and folder naming. Case matters!
- Do your code pools match? (
Now you can start developing for Magento!