Magento Themes and Magento Extensions

Magento – MVC Structure and Code Organization

Share

Code Organized in Modules
Magento organizes its code into individual Modules. In a typical PHP Model-View-Controller (MVC) application, all the Controllers will be in one folder, all the Models in another, etc. In Magento, files are grouped together based on functionality, which are called modules in Magento.

Magento’s Code

For example, you’ll find Controllers, Models, Helpers, Blocks, etc. related to Magento’s checkout functionality in

app/code/core/Mage/Checkout
You’ll find Controllers, Models, Helpers, Blocks, etc. related to Magento’s Google Checkout functionality in

app/code/core/Mage/GoogleCheckout
Your Code
When you want to customize or extend Magento, rather than editing core files directly, or even placing you new Controllers, Models, Helpers, Blocks, etc. next to Magento code, you’ll create your own Modules in

app/code/local/Package/Modulename
Package (also often referred to as a Namespace) is a unique name that identifies your company or organization. The intent is that each member of the world-wide Magento community will use their own Package name when creating modules in order to avoid colliding with another user’s code.

When you create a new Module, you need to tell Magento about it. This is done by adding an XML file to the folder:

app/etc/modules
There are two kinds of files in this folder, the first enables an individual Module, and is named in the form: Packagename_Modulename.xml

The second is a file that will enable multiple Modules from a Package/Namespace, and is named in the form: Packagename_All.xml

Comments are closed.