Go back

Magento, the King of eCommerce. Part II.

By Miguel Balparda, Magento Developer at Santex

Today I will be developing some concepts and ideas regarding the architecture of Magento and its components.

The Zend Framework

As I stated in my last article, Magento is an open source web application based on one of today’s most popular and most complete frameworks: the Zend Framework. This particular framework has grown into a very popular trend within the eCommerce world. It should be no surprise that the Zend Framework is one of the best options in the market due to its simplicity and modularity. Each of its components have few dependencies between each other, are 100% object oriented, and are regularly updated because they use new features of the latest versions of PHP.

Over the years, the number of ZF users has grown exponentially, leading to the creation of a vibrant and active community. This escalation in interaction also constitutes a fundamental part of the development of this framework.

Magento Architecture and the use of Observers

Regarding the Magento architecture, the application uses a slightly different approach from the well-known MVC pattern. In the Magento world, it is referred to as configuration driven MVC.

The most striking differences between the traditional pattern and the Magento one are as follows:

  • The use of layouts to manage the views.
  • The use of blocks to control the views and to profit from thin controllers.
  • The use of model rewrite systems.
  • The use of Observers (one of the most powerful features in Magento).

Since I regard Observers as one of the most powerful features in Magento, I will dig a little deeper into the use of Observers. In a nutshell, what do Observers do? Observers look for specific events in order to perform an action. An event is something that occurs in a certain place during a particular sequence flow, such as a user login or an add to cart.

By just creating an observer class, a module can modify objects without overriding any other class. This is particularly helpful to avoid conflicts with other extensions that might be present in the system. The main problem is that Magento doesn’t have an official list of events, but one can always use the unofficial list for reference and to check the core classes to see which events are being fired when. Though it may not seem as important at first, once one is into the world of developing a module, one may find this one of the most useful features in the system.

Magento database architecture

Another thing to keep in mind about Magento is the architecture of the database. Magento uses EAV (entity-attribute-value) for most of the database tables. EAV is a data model used to describe entities where there are a number of attributes (properties, parameters).  The number of attributes is potentially very vast, but the actual number is relatively modest. The opportunity cost of flexibility is, as is always the case, the complexity.

In practice, this means one will not find all the attributes of a product or a category in a single table but in many. The EAV tables are identified by the “eav_“ prefix in the database for a better understanding. This can be changed for a better performance. A Magento store will need a heavily optimized server to run properly because the database server will be making a big amount of queries for every record loaded.

We have gone over important aspects regarding the Zend Framework, the use of Observers, and Magento Database architecture. In my next article I will be writing about server optimization for better Magento performance.

About the author

Miguel Balparda has been developing Magento for almost four years. During this time, he has witnessed the exponential growth the platform has undergone; today it is one of the largest and most popular online stores in the world. There is a great deal of documentation and resources available for both merchants and developers. It is best to start by scanning the official Magento website, where you can find resources to get in touch with the application, as well as free extensions to learn the structure of modules. Miguel can be contacted at communications@santexgroup.com