Module structure

 

  • Block

    • Contains model classes which relate to a template file. Each block model contains the logic for a template. Block functions can then be called using $this from within the template.

  • Controllers

    • The controllers determine the url routes and are mainly there to control the link between the end user and the application. The controllers should be light and should use other parts of the application for any heavy lifting.

  • data

  • etc

    • This holds the config files for a module.

  • Helper

    • This is a folder for helper classes. There is a factory method which gets a helper using Mage::helper.

  • Model

    • This contains the Model classes for the module. The Magento models are slightly different from the traditional MVC models. A traditional MVC Model is used to link a PHP object with a data source, which is a database in this case. With Magento there are Models and there are also resource models. Only the resource models communicate with the database.

  • Sql

    • Contains the install and upgrade scripts for database migrations.