Magento Backend Tutorial – Module Structure

Code pools

  • community – reserved for extensions available through public marketplaces (ex. Magento Connect).
  • core – contains the base Magento application, separated into two namespaces: Mage & Enterprise. Files in this pool should never be edited directly.
  • local – customizations, overrides, etc. should all be placed into this namespace.

Namespaces & modules

Typically, code created for a given project carries the agency’s or the client’s name, and is placed inside the local pool (ex. app/code/local/YourTheme). All custom modules then reside inside this namespace.

Module code

Every module must contain its own configuration file (“etc/config.xml”), but presence of other components varies on individual needs. Below is the list of potential components.

NameDirectoryPurpose
BlocksBlockPrepare data for presentation (methods from a block associated with a given template file can be accessed using $this inside the .phtml file).
ControllerscontrollersResponsible for processing frontend requests, by matching them to declared actions (methods). As per Zend Framework best practices, controllers should be kept as skinny as possible, and business logic should be left to the models.
ConfigurationetcContains XML configuration files for the given module, including declarations, API capabilities (used in WSDL), frontend routing, admin routing, system configuration forms, FPC settings.
HelpersHelperAuxiliary methods for commonly used operations.
ModelsModelBusiness logic.
Resource ModelsModel/ResourceProvide access to the data in the database.
Schema SQL ScriptssqlCreate and modify database schema.
Data SQL ScriptssqlModify data in the database (ex. insert a list of ZIP codes for a store locator table).