Hello every one,

You must have heard the hottest news in Magento Community: Magento Certificate exam! Are you going to join that test? If so, don’t miss the huge and comprehensive resource of Magento brought you by us. Keep your eyes on our Blog every Friday for the latest posts. We will cover the whole 10 content areas which are in the Magento test form, started with the first chapter Basics this week.

Magento is built based on Principles of Object-Oriented Programming on Zend Framework with MVC architecture and use Event-Driven Architecture (EDA) to manage events.

In this post, we will talk about:

  1. Describe and apply basic principles and processes of Object Oriented Programming (OOP) and Model-View-Controller (MVC) to build Magento websites
  2. Identify and describe the principles of Event-Driven Architecture (EDA)
  3. Sample questions & answers

I- Describe and apply basic principles and processes of Object Oriented Programming (OOP) and Model-View-Controller (MVC) to build Magento websites

1. Object Oriented Programming OOP

    • Abstraction

Use function/class without knowing exactly how that function/class accomplishes its tasks. What we care is parameters sent to it and its returned value
A typical example is function _init() in class Mage_Core_Model_Abstract, this function will be executed to define the model will work with which table in CSDL.
– Inherited class of Abstract class is just the instance of the abstract class.
– Calling abstract function requires its instance function, which means in the children class you must rewrite this function.

    • Encapsulation

Objects are encapsulated. When changing data, you must go through functions to work with that object. In other words, a product cannot know information of another product. The common between the 2 products is the method working with them.

    • Polymorphism

Object instances of a same class are different. For example, products of different types (simple/grouped/…) have different price calculated method.

    • Inheritance

Inheritance is exploited in Magento, especially Varien_Object class which is inherited by many classes in Magento. (Function setData/getData is inherited from Varien_Object).

2. Model-View-Controller MVC

    • Model

Model is the classes providing data, service related to data and business logic. This class works directly with data and provides data for other elements. In a module, these classes are contained in Model folder.

    • View

View is the classes which define data presented method (not update data). These classes are contained in the folder Block of module.

    • Controller

Controller is the classes which control application stream. They receive input which is requirement of users through HTTP request, transfer those requests to the classes which process the requests directly. From the link, Router will get to Controller which controls that link. In Magento module, these classes are contained in controller folder.

II-Identify and describe the principles of Event-Driven Architecture (EDA)

1. Event-Driven Architecture

  • Event Listener & Generator: When an event happens, this element will Listen the event, create signals of that event and send that signal to Event Engine.
  • Event Engine: When receiving signals of the event, this element will send them to factor Client to process that event.
  • Client: When receiving signals of the event, this element will execute steps to respond to that event.

2. Mangento Event

  • Event Listener & Generator: is function Mage::dispatchEvent().
  • Event Engine: function Mage_Core_Model_App::dispatchEvent() reads config (xml) and send signals to Client (by calling function  _callObserverMethod()).
  • Client: are functions of modules that catch the event.

III-Question

1. What is static function?

Static function is silent function of a class, which is stored in the memory space of a class (not objects).

2. The order of event when several modules catch the same event?

Order of event: Which module is first loaded will get the signals before others. The order of loading module depends on the name of module and configure of module:

– Module depends on another module will be loaded later than the module it depends.

– Order of loading configure of module is as below:

    *Mage_All.xml will be loaded first, module configure in this file will be loaded first

*Mage_*.xml

*.xml

And file.xml will be loaded according to the order of the file’s name.

Somehow basics knowledge is more difficult to understand than others, do you think so?

How to pass Magento certification exam

Author

Why Magestore? We believe in building a meaningful & long-term relationship with you.

10 Comments

  1. Static function can only be called from class – this is not true

  2. David Nguyen Reply

    Thank you for your contribution! That’s right, static function can be called from class or object. We will edit our post.
    Welcome any ideas or questions from everyone! This is the place for us to learn together.

  3. this tutorial is very useful for me,i am very thankful for this. I will read this all fridays.

  4. I have the below question, can please review it.

    1) Identify the function and proper use of automatically available events, including *_load_after, etc.
    2) What are the common methods with which the framework accesses its configuration values and areas?
    3) How are per-store configuration values established in the XML DOM?
    4) By what process do the factory methods and autoloader enable class instantiation?
    5) What are the interface and configuration options for automatically fired events?
    6) What is the structure of event observers, and how are properties accessed therein?
    7) Describe the use of Magento translate classes and translate files
    8) Describe the advantages and disadvantages of using subdomains and subdirectories in internationalization

    • Hi,
      Thanks for your comment. You can easily find the answers for all of your questions in our other tutorials in Basics category. If there’re any further questions, please feel free to leave comments. We will help you resolve them.

  5. can we set module load order ?
    is there any xml tag is there for load the module in order? some thing like postion,sortorder
    if there how to do it

    • Hi paradeep,
      There is no xml tag as you mentioned. Magento sets module load order depending on Name and config <depends> and doesn’t have any tag like position, sort_order. You can see the code to load module in Magento in function _loadDeclaredModules, _sortModuleDepends in the file app\code\core\Mage\Core\Model\Config.php.
      Hope it helps.

Write A Comment