Magento module structure – Part 2

Block
Block is generally will call view in a classical MVC architecture. Block files will co-ordinate with model and template files. Block file are load the data from the database and transfer to the template files.

Controllers
Controllers represent all business logic actions for the given request (dispatch(), preDispatch(), postDispatch() methods) and delegate commands to other parts of the system. If i run the any URL from the browser, it will redirect to controller files.

etc
This folder contain all the xml files and configure behaviour of all modules. Each module must have at least config.xml at least, if you want to create any module or block or controller or model files then we have to declare our xml setup in this file

config.xml , adminhtml.xml , system.xml

config.xml

Related to model , controller, block file configuration we have to declare in this file.

adminhtml.xml

We can use this file for admin section related xml declaration.

Ex: ACL grant permissions for tab and backend menus

system.xml

Creates this new section or specifies where it should be displayed in existing one.

Ex: If you want to create one mobile number text field under system configuration tab then we can use this file to declared our code.

Helper

From name name itself we come to know the use of this folder files. Yes, this files will helping class or file to different way. This files contain the utility methods, which are commonly used in whole system.We can use this helper class function from anywhere from the template or block or model or controller files. Data.php file is the mandatory file in helper class folder.

Model :
In classical MVC, Models are used to connect to the database and process the data from and to it. Magento has a different approach, which can be tricky at first look.
Magento Models can categorized in one of two ways. There’s a basic one-object-one-table Model, and there’s also an Entity Attribute Value (EAV) Model. Each Model also gets a Model Collection. Collections are PHP objects used to hold a number of individual Magento Model instances.

sql:
If you are going to use new database column with existing magento tables, or going to create your own custom table then those declaration should be in this file. Handles any custom database tables which will be used by the module and process all upgrades to the extension.

————————————————————————————————————————————————————–

Corner of Blog:

“Don’t Drink and Drive. Enjoy life with out Drink”

————————————————————————————————————————————————————–