In order to continue Magento Tutorial this week, I will lead you to Magento directory structure. Please follow it carefully!
Magento is built based on the principle of object-oriented programming with MVC architecture. The code system of Magento is saved in the form of dispersions so as to increase extension ability for the system. The directory structure is stored as the followings:
I – Magento directory structure

II – The structure of module

1. The best way to understand Magento is to know structures and activities of modules in Magento. The entire code of one module is contained in a directory in app/code/core/Mage

2. The following is the structure of a module catalog: You must use article before a singular noun: a/the/my…

  • Block: monitors the template system in Magento. The code in block is used to load database and display of template. This is also the location to edit database if necessary before showing it on the template. The display of which template will be declared in the layout file: app/design/frontend/default/default/layout/your_module.xml.

For example:

<reference name=“content”>
<block type= “yourmodule/yourblock” name= “your_name” template= 

When clients access the link: , Magento will analyze this URL to find out names of module, controller and action which are called out. And then, it will search in layout files to view the template which will be used to display

Here is the file yourmodule/yourtemplate.phtml

  • Etc: contains XML files which are used to configure each module. There are three important files:
    * Config.xml: directly configures module and declares Module, Resource, Block, and Helper…

* System.xml: configures default value and display in admin menu.

* Adminhtml.xml: creates menu in admin.

  • Model: handles the process of the database access. Magento designs database according to the EAV model so the database access is quite complicated. This is the place to write functions which directly carry out queries.
  • Controllers: define process to execute request of users. Controllers are classes which inherit from the basic one:  Mage_core_Controller_Varien_Action (inherits from class Zend_Controller_Action).
  • Helper: you can add functions here in order to do anything as you wish. To call one function (Ex: helper Test) in Helper, you need to use the command below: Mage::helper(‘yourmodule/yourhelp’)->helperTest();
  • Sql: contains files to setup database for module which interact with database (create table, update tables…)
  • Besides, there are layout and template files for admin and frontend in the folder: app/design/adminhtml/default/default and app/design/frontend/default/default.
  • To declare Magento a new module you need to create a XML file Yournamespace_Yourmodule.xml

<?xml version="1.0"?>
</ Yournamespace_Yourmodule >

III – Question
1. What is the compilation mode in Magento?
The mode inserts class files into a folder in order to speed up in Magento. In order to use this function, you need to go to menu system->website->compilation in admin.
2. Then entering the link below into the Address bar of browser, which Module, Controller and Action will Magento call?
a. Module: module      Controller: controller      Action: action
b. Module: action         Controller: controller      Action: module
c. Module: action         Controller: module          Action: controller
After following this post, can you please give the correct answer for this question?
Hope for your answer much! 🙂


Why Magestore? We believe in building a meaningful & long-term relationship with you.


Write A Comment