Magento is a stable solution, secure, and fully customizable, as well as being an e-commerce platform with many features, making it one of the leading and most comprehensive development tools. Built on an open source technology, this language provides developers unprecedented flexibility and total control over the look, content and functionality of their eCommerce store.
This tool is designed for scalable way that has an intuitive and robust control panel, that is, besides having a huge range of features, they are presented clearly and effectively ensuring its usability.
Other important points to highlight are the marketing tools, SEO (Search Engine Optimization) and catalog management tools that enable the creation of fully adaptable sites to your needs or your customers.
What is Magento?
When we talk about e-commerce platform with highly customizable management system, we are talking about Magento. With its use is possible to develop virtual stores of any segment and enjoy various features such as shopping carts, inventory management, payment and others.
The essential principles of Magento's product architecture include OOP and programming principles. The object-oriented programming allows for maximum flexibility and scalability of software components, allowing you to design and implement fully customized web sites. The advantages of OOP principles include incorporating known design patterns and strict separation of presentation from business logic. It also provides the core components with basic functionality that can be inherited by custom components to a particular site or application.
If you want to know more about data models and content platforms (including Magento), please refer to our tutorials course below:
- Analysis of the WordPress, Joomla, Drupal and Magento data models – Part 1
- Analysis of the WordPress, Joomla, Drupal and Magento data models – Part 2
- Analysis of the WordPress, Joomla, Drupal and Magento data models – Part 3
- Analysis of the WordPress, Joomla, Drupal and Magento data models – Part 4
There is a separation of design and business logic, simplifying the customization of the shop, and the look and feel. Architectural layers can also provide a high-level model to understand the most efficient positioning of resources and code in a complex system. The Magento tweaks the MVC model, however, files within modules are typically grouped by functionality rather than file type.
The Magento defines the basic concepts and rules of how the web site components can behave. It also contains libraries of access modules, but there is no business logic components. This language accepts HTTP requests and forwards them to the appropriate module.
- Extension facility: the Magento technology uses dependency injection and service contracts to simplify the process of providing new implementation of a defined API. The dependency injection benefits include knowing the module or service without knowing them properly, and you can change them without changing the client anywhere as long as you use the dependency injection framework for the application logic. Furthermore, service contracts provide a new way to access terminals via the public API PHP interfaces.
- Modularity: modules form the functional unit of the base of the Magento system, containing the logic to perform specific actions and functions.
The diagram in Figure 1 shows the components of Magento and its layers for all components such as presentation layer, service layer, domain layer and persistence layer.
Figure 1. Architecture Diagram
- Presentation Layer: when you interact with the Magento web interface, you're working directly with the code of this layer, which contains elements such as layouts, blocks, templates, and drivers who run the UI process. The presentation code controls the interaction of the web user with the product and its appearance. You can customize the user interface using HTML, CSS and .phtml files to modify elements of the presentation layer;
- Service Layer: provides a bridge between the presentation layer and logic layer domain and specific data resources. This is implemented using service contracts, which are defined using PHP interfaces. On the service layer we have: the Reside below the presentation layer and above the domain layer, the Contains service contracts that define how the implementation will behave; it provides an easy way to access the REST/SOAP through the code API framework (which also lies above service contracts). You can link the service contracts for web services APIs for configuration files with no coding required; theyProvidea stable API to other modules.
- Domain layer: keeps the business logic layer of a Magento module. It usually does not contain specific information resource or specific database. Its main functions include: Defines the Magento generic objects data or templates that contain business logic. This logic defines operations that can be performed on particular data types, such as a customer object. These models contain only generic information. Applications can also use SOAP or RESTful endpoints to request data models; (Optionaly) Includes the implementation of service contracts, though not its definition; As best practices we can use service contracts to communicate with the domain layer passing types of data objects using strongly typed ones. This practice can help to prevent the replacement presentation layer code to replace the business logic layer;
- Persistence layer: Magento uses an active strategy for continued registration pattern. In this system, the object model has a resource model that maps an object to one or more rows of the database. A resource model is responsible for performing functions such as: Implementation of all CRUD applications, that is, the resource model containing the SQL code to complete these requests; Implementing additional business logic, for example, a Model feature could perform data validation, initiate processes before or after the data is saved, or perform other database operations; If you return multiple items in a database query, you can implement a special type of model feature known as collection, which is a class that carries several models in an array-like structure based on a set of rules. This is similar to an SQL clause WHERE. A simple resource model defines and interacts with a single table. However, some objects have a number of attributes or they might have a set linking objects that have a varying number of attributes. In these cases, objects are constructed using entity attribute value (EAV). As a result, any model that uses a EAV resource has its attributes distributed across a number of MySQLtables. The customer models amd catalog resources use EAV attributes.
Magento provides a set of robust tools for deploying large stores, and to customize the product for your particular needs. The technologies involved are popular and open source, like Linux operating system, and the following technologies:
- PHP (5.5 and 5.6);
- CSS3 (LESS CSS pre-processor);
- Zend Framework 1, Zend Framework and Symfony 2;
- Apache 2.2, 2.4;
- Nginx 1.7;
- MySQL 5.6;
- Composer (dependency management package for PHP);
It also has optional stack components:
- Varnish (caching);
- Pens (used for session or page cache);
- Solr (search engine).
Server settings to fit the Magento
The development environment must rely on Apache (versions 2.2.x, 2.0.x, 1.3.x) and Nginx 1.7.x (for CE1.7 or EE 1:12 or higher). As host we need capability to run scheduled tasks (crontab), so we use PHP 5 to override options in .htaccess files.
The installed PHP safe_mode must rely on off mode and memory_limit with no less than 256 MB (512 MB is recommended). In addition, the following extensions should be installed:
- Pdo_mysql-DOM to work with the database;
- simplexml -iconv for XML manipulation;
- mcrypt -curl, to encrypt and decrypt;
- hash -SOAP (for Web services API), also to encrypt and decrypt;
- GD to work with images.
In addition, a valid safety certificate is required for HTTPS. Remember that self-signed certificates are not supported. It is highly recommended to run both on site and in the Admin the HTTPS.
Understanding the Magento folder structure
The folder structure was developed by dividing groups of modules, or each module is separated by functionality, thus minimizing the dependencies among other modules as shown in Figure 2.
Figure 2. Folder structure
Let us understand the most important folders:
- Core - Here we find the basis of Magento and there are several configuration files, database schema, rendering objects, data models, control actions and etc.. This folder is the heart of Magento, never change a comma in this folder because the change may compromise new updates and security enhancements;
- Community - Here we find the modules installed via "magento connect" from the Magento dashboard. If this installation is done manually is recommended to use this directory;
- Location - This folder is dedicated to customization of modules developed for a particular store, that is, this is where we add our modules;
- Design - found handling files from admin panel design and structure of the front end, as a template, layout, etc .;
- Etc. - Some global configuration files of Magento are here, like the access to the database, encryption key, paths of some areas of the system, among others;
- Locale - this folder finds the CSV files, which are responsible for configuration of languages. The default is en_US, but the latest versions of Magento comes with more. If you don't like any terms just edit these files;
This platform is one of the most complete solutions on the market today and this article demonstrated how this tool can be useful in your day to day as a developer. Please refer to some of our links in the Links section below for more information.
Official website of Magento