Hi everyone,
I’m Stephen. Today I will continue the Topic 1: Basic with the next part- Magento Module-based architecture.
Magento is built based on module architecture. All activities of Magento are processed by modules.
In this post we will talk about:
1. Describe module architecture
2. List steps to add a new module
3. Describe module limitations
4. Sample questions & answers
I - Describe module architecture
A built module of Magento may work following the structure: MVC (model – view –control) with functions of each are below:
- Model: is the element which works with data, stores and takes out data. Model will make sure data’s performance and accuracy.
- View: is the expression of data, showing changes of system to users.
- Control: is the element which controls interaction between view and model, processing application stream.
MVC in Magento: http://www.magentocommerce.com/wiki/_media/general/doc/page-request-flow.png
Besides, module in magento may be built based on EDA architecture to send and catch events in the system (EDA architecture has been mentioned in part 1- Fundamentals).
II - List steps to add a new module
To add a new module in Magento, we need at least 2 following steps:
Step 1: Register module with the system by naming file configure (e.g. file Magestore_Test.xml into the folder /app/etc/modules/. File Magestore_Test.xml with the content like this:
<?xml version="1.0"?>
<config>
<modules>
<Magestore_Test>
<active>true</active>
<codePool>local</codePool>
</Magestore_Test>
</modules>
</config>
Step 2: Create code in folder /app/code/local/Magestore/Test. Files needed for module will be shown in the next parts.
III - Describe module limitations
Limitations of modules:
- All activities of the system must go through modules and an action in Magento may involve some modules, thus the loading and running of Magento system is quite slow.
- Many modules work in the same system can lead to modules’ conflict.
IV – Questions
1. Q: When the system runs, does it load all files in module? If not, why when creating a new object or extend class from a class without including class’s source file, the system does not show errors?
A: When running Magento, the system will just load files including the class which we called.
Magento uses a magic function spl_autoload_register(‘name_function_autoload’); of PHP. When you create a new object or extend class from a class that doesn’t exist, the function name_function_autoload will automatically run before adding new or extending from a class.
The function name_function_autoload has parameter named class, so it’s the type function name_function_autoload(class). In Magento, from the name of a class, the system can immediately find the path and files including that class (due to rules of naming in Magento).
Is this post useful to you? Hope so
I will be pleased to answer or discuss any questions with you guys.

Related Posts

Add Your Comment

Discussion
5 comments



My Cart
Checkout
My Account

















5