Magento Modules

Posted: August 11, 2011 in Magento, PHP

Magento consists of modules and as a result modules are the core of Magento. When you consider every action that takes place in Magento both Front/Back-end, they all go through a module.  Modules act as containers for one or more of the following : Settings, Database schemas,   rendering objects, Utility helpers, data models, or action controllers.Modules can be made up of all six of these or just one.

Magento has come up with a way to have a well designed code base and still have it extendable by creating Code Pools which are folders/directories that contain modules in Magento and they consist of three code pools local, community and core. All custom made modules you develop can be installed in the local code pool, all modules distributed with the base  Magento are in the core code pool and the community code pool was initially for third party modules but they can now be installed on both local and community.

Models are also a very important aspect of Magento as they are the muscles. They mainly help with moving data from the database to the program itself and they are also responsible for manipulating the data.

Blocks help with Magento’s templating scheme. They are a HTML and PHP mixed file with phtml extension and each block controls one template file. All blocks extend the base class Mage_Core_Block_Template which extends Mage_Core_Block_Abstract.

Controllers in Magento are the starting point for all the business logic. Controllers extend the base class Mage_Core_Controller_Varien_Action which has three important classes :

  • dispatch($action)
  • preDispatch()
  • postDispatch()
Helpers are pretty much standard in every thing you do or find and the same is applied to Magento as they are a way to restructure an existing body of code out of the core classes.
The two major methods of helpers to look out for are :
  1. __ (two underscores)
  • This method is a translation helper
  1. htmlEscape
Config files
There are three different config files available (config.xml, system.xml and convert.xml) and they are found in the etc folder under the main directory all of which are XML. config.xml is the only config file that directly affects your modules behavior.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s