Create your first module

Whenever you want to change something in your Magento, it is a good practise not to modify core files of the system, but instead create new module which will extend or override those file.
After reading this short article you will know how to create Magento module and how to activate it in your administration.

All Magento modules are stored in directory app/code/

As you can see there are two other directories app/code/community/ and app/code/core/

We will create directory app/code/local/ where our new module will be stored.

Prepare your module file structure

When we want to create new module, we have to create Magento specific file structure. For that you’ll have to pick proper name space and module name. Usually as a name space people use company name, but it’s completely up to you.  Let’s say that my name space will me Lukas and module name will be Test.

Now in your Magento folder create structure like you can see on a following picture. The yellow one are directories you already have, the others, you have to create manually.

 

Create necessary files in your module

Create file app/code/local/Lukas/Test/etc/config.xml

<config>
  <modules>
    <Lukas_Test> 
      <version>1.0.0</version>
    </Lukas_Test>
  </modules>
</config>

 

Tell Magento to register your module

On page request Mageto put every xml configuration file together into one large monstrous xml. Therefore we need to tell Magento, that we created new module.

just create new xml file with name app/etc/modules/[company name]_[module name].xml

<config>
  <modules>
  	<Lukas_Test>
    <active>true</active>
  	<codePool>local</codePool>
    </Lukas_Test>
  </modules>
</config>

Disable/Enable the module in Admin panel

In our xml file we wrote node <activate>true</activate> which makes our module enabled from the beginning. In case you would want to deactivate it, just go to:

System > Configuration > Advanced

find your module, and make it disabled. Make sure that you have cleared the Magento caches.


Lukas
Lukas Stranovsky
I am the guy who made this. Sorry for typos.