{"id":15644,"date":"2018-04-26T15:53:45","date_gmt":"2018-04-26T13:53:45","guid":{"rendered":"https:\/\/belvg.com\/blog\/?p=15644"},"modified":"2021-02-18T14:03:30","modified_gmt":"2021-02-18T12:03:30","slug":"magento-2-architecture-how-is-it-used-in-magento-2-application","status":"publish","type":"post","link":"https:\/\/belvg.com\/blog\/magento-2-architecture-how-is-it-used-in-magento-2-application.html","title":{"rendered":"Magento 2 Architecture. Service Layer"},"content":{"rendered":"\n<p>Understanding layered software&nbsp;architecture is essential for understanding basic Magento product organization. In this article we are going to provide a detailed explanation of each of the 4 layers in Magento 2 and the way they are used in Magento 2 application. After that we will take a close-up look at Service layer, there is a lot to talk about.<\/p>\n<p><!--more--><\/p>\n<p>Magento 2 Architecture can be divided into the following layers:<\/p>\n<ul>\n<li><span style=\"color: #000000;\">Presentation layer;<\/span><\/li>\n<li><span style=\"color: #000000;\">Service layer;<\/span><\/li>\n<li><span style=\"color: #000000;\">Domain layer;<\/span><\/li>\n<li><span style=\"color: #000000;\">Persistence layer.<\/span><\/li>\n<\/ul>\n<p>These layers, that also include components,&nbsp;are demonstrated on the following diagram:<\/p>\n<p>&nbsp;<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"lazy aligncenter size-full wp-image-15645\" src=\"https:\/\/belvg.com\/wp-content\/uploads\/2019\/06\/pixel.png\" data-src=\"https:\/\/belvg.com\/blog\/wp-content\/uploads\/2018\/04\/image2.png\" alt=\"Magento architecture\" width=\"720\" height=\"540\" title=\"Magento 2 Architecture. Service Layer\"><\/p>\n<h2><strong><span style=\"color: #000000;\">Presentation Layer<\/span><\/strong><\/h2>\n<p>Presentation layer includes a view of the administrative part of the site, an API call, and a view for site users. This level consists of such components as layouts, blocks, templates and controllers. The view code controls the user\/administrator interaction with the store and its appearance. Presentation layer components call the Service layer, which in its turn sends queries to Domain layer.<\/p>\n<h2><strong><span style=\"color: #000000;\">Service Layer<\/span><\/strong><\/h2>\n<p>Service layer serves as a bridge between Presentation layer and Domain layer. This is implemented using service contracts, which are defined using PHP interfaces. All the calls from web service interfaces (API) or users (controllers) are routed through Service layer. This allows you to separate the business logic from the code. Service contract includes:<\/p>\n<ul>\n<li><span style=\"color: #000000;\">Controllers;<\/span><\/li>\n<li><span style=\"color: #000000;\">Web services (SOAP and REST API calls);<\/span><\/li>\n<li><span style=\"color: #000000;\">Third-party modules using service contracts.<\/span><\/li>\n<\/ul>\n<h2><span style=\"color: #000000;\"><strong>Domain Layer<\/strong><\/span><\/h2>\n<p>Domain layer contains the level of the module&rsquo;s business logic. It usually does not contain the information specific to a particular resource or database. Its main functions include:<\/p>\n<ul>\n<li><span style=\"color: #000000;\">identifying common Magento data objects or models that contain business logic; <\/span><\/li>\n<li><span style=\"color: #000000;\">(optional) implementation of service contracts.<\/span><\/li>\n<\/ul>\n<h2><span style=\"color: #000000;\"><strong>Persistence Layer<\/strong><\/span><\/h2>\n<p>Magento uses the &ldquo;active record&rdquo; pattern for saving. In Magento, the model object contains a &ldquo;resource model&rdquo; that compares the object with one or more database records. &ldquo;Resource model&rdquo; is responsible for performing such functions as:<\/p>\n<ul>\n<li><span style=\"color: #000000;\">Executing all CRUD requests. The resource model contains the SQL code for executing these queries;<\/span><\/li>\n<li><span style=\"color: #000000;\">Performing additional business logic. For example, a resource model can perform data validation, run processes before or after saving data, or perform other operations on the database.<\/span><\/li>\n<\/ul>\n<p>If you expect to return multiple items from a database query, you must implement a special type of &ldquo;Resource model&rdquo;, known as &ldquo;collection&rdquo;. &ldquo;Collection&rdquo; is a class that loads several models into a structure similar to an array, based on a set of rules.<\/p>\n<p>Now let us take a closer look at Service layer in Magento 2.<\/p>\n<h2><strong><span style=\"color: #000000;\">Magento 2 Service Layer<\/span><\/strong><\/h2>\n<p>Service layer In Magento 2 is a new layer that lies between Presentation layer and the business logic. The goal is to make all calls from other modules, as well calls from Presentation layer (blocks, templates and controllers) pass through Service layer. Besides that, Service layer can be easily opened as a REST web service or a SOAP endpoint.<\/p>\n<p>Service layer for the module is a set of PHP interfaces, data types, and the implementation of these interfaces. Let&rsquo;s take the Customer Interface class code as an example, with the names of the fields of the entity being a constant, and the methods get () and set () serving to write data in the entity table and the module&rsquo;s attributes. Also note that in PHPDoc we define the type of the field value. We describe the fields of the user object as following:<\/p>\n<pre class=\"lang:php decode:true\">&lt;?php\r\nnamespace Magento\\Customer\\Api\\Data;\r\n\r\ninterface CustomerInterface extends \\Magento\\Framework\\Api\\CustomAttributesDataInterface\r\n{\r\n&nbsp;&nbsp;&nbsp;...\r\n&nbsp;&nbsp;&nbsp;const FIRSTNAME = 'firstname';\r\n&nbsp;&nbsp;&nbsp;...\r\n&nbsp;&nbsp;&nbsp;\/**\r\n&nbsp;&nbsp;&nbsp;&nbsp;* Get first name\r\n&nbsp;&nbsp;&nbsp;&nbsp;*\r\n&nbsp;&nbsp;&nbsp;&nbsp;* @return string\r\n&nbsp;&nbsp;&nbsp;&nbsp;*\/\r\n&nbsp;&nbsp;&nbsp;public function getFirstname();\r\n&nbsp;&nbsp;&nbsp;\/**\r\n&nbsp;&nbsp;&nbsp;&nbsp;* Set first name\r\n&nbsp;&nbsp;&nbsp;&nbsp;*\r\n&nbsp;&nbsp;&nbsp;&nbsp;* @param string $firstname\r\n&nbsp;&nbsp;&nbsp;&nbsp;* @return $this\r\n&nbsp;&nbsp;&nbsp;&nbsp;*\/\r\n&nbsp;&nbsp;&nbsp;public function setFirstname($firstname);\r\n&nbsp;&nbsp;&nbsp;...<\/pre>\n<p>To implement &nbsp;CRUD in Magento 2, we need to describe the repository interface and implement it. We can take the Customer Repository Interface as an example, which describes the methods of working with the customer object. As you can see, this implementation simplifies the work with different versions of the module, since we have one entry point through the API and the implementation is separated. If a new mandatory field is added to the entity, it is going to be an exceptional case.<\/p>\n<pre class=\"lang:php decode:true\">&lt;?php\r\n\/**\r\n*\r\n* Copyright (c) Magento, Inc. All rights reserved.\r\n* See COPYING.txt for license details.\r\n*\/\r\nnamespace Magento\\Customer\\Api;\r\n\/**\r\n* Customer CRUD interface.\r\n* @api\r\n* @since 100.0.2\r\n*\/\r\ninterface CustomerRepositoryInterface\r\n{\r\n&nbsp;&nbsp;&nbsp;\/**\r\n&nbsp;&nbsp;&nbsp;&nbsp;* Create or update a customer.\r\n&nbsp;&nbsp;&nbsp;&nbsp;*\r\n&nbsp;&nbsp;&nbsp;&nbsp;* @param \\Magento\\Customer\\Api\\Data\\CustomerInterface $customer\r\n&nbsp;&nbsp;&nbsp;&nbsp;* @param string $passwordHash\r\n&nbsp;&nbsp;&nbsp;&nbsp;* @return \\Magento\\Customer\\Api\\Data\\CustomerInterface\r\n&nbsp;&nbsp;&nbsp;&nbsp;* @throws \\Magento\\Framework\\Exception\\InputException If bad input is provided\r\n&nbsp;&nbsp;&nbsp;&nbsp;* @throws \\Magento\\Framework\\Exception\\State\\InputMismatchException If the provided email is already used\r\n&nbsp;&nbsp;&nbsp;&nbsp;* @throws \\Magento\\Framework\\Exception\\LocalizedException\r\n&nbsp;&nbsp;&nbsp;&nbsp;*\/\r\n&nbsp;&nbsp;&nbsp;public function save(\\Magento\\Customer\\Api\\Data\\CustomerInterface $customer, $passwordHash = null);\r\n...<\/pre>\n<p>Service layer also includes Management interfaces, which provide management functions, not associated with the repositories. They do not perform any operations to change the data. Let&rsquo;s consider the example of Account Management Interface:<\/p>\n<pre class=\"lang:php decode:true\">&lt;?php\r\n\/**\r\n*\r\n* Copyright (c) Magento, Inc. All rights reserved.\r\n* See COPYING.txt for license details.\r\n*\/\r\nnamespace Magento\\Customer\\Api;\r\n\/**\r\n* Interface for managing customers accounts.\r\n* @api\r\n* @since 100.0.2\r\n*\/\r\ninterface AccountManagementInterface\r\n{\r\n&nbsp;&nbsp;....\r\n&nbsp;&nbsp;&nbsp;\/**\r\n&nbsp;&nbsp;&nbsp;&nbsp;* Check if customer can be deleted.\r\n&nbsp;&nbsp;&nbsp;&nbsp;*\r\n&nbsp;&nbsp;&nbsp;&nbsp;* @api\r\n&nbsp;&nbsp;&nbsp;&nbsp;* @param int $customerId\r\n&nbsp;&nbsp;&nbsp;&nbsp;* @return bool\r\n&nbsp;&nbsp;&nbsp;&nbsp;* @throws \\Magento\\Framework\\Exception\\NoSuchEntityException If group is not found\r\n&nbsp;&nbsp;&nbsp;&nbsp;* @throws \\Magento\\Framework\\Exception\\LocalizedException\r\n&nbsp;&nbsp;&nbsp;&nbsp;*\/\r\n&nbsp;&nbsp;&nbsp;public function isReadonly($customerId);\r\n&nbsp;&nbsp;....<\/pre>\n<p>Service layer also includes Metadata interfaces. Metadata is data, that describes other data. To see the example of this interface, let&rsquo;s look at the Address Metadata Interface:<\/p>\n<pre class=\"lang:php decode:true\">&lt;?php\r\n\/**\r\n* Copyright (c) Magento, Inc. All rights reserved.\r\n* See COPYING.txt for license details.\r\n*\/\r\nnamespace Magento\\Customer\\Api;\r\n\/**\r\n* Interface for retrieval information about customer address attributes metadata.\r\n* @api\r\n* @since 100.0.2\r\n*\/\r\ninterface AddressMetadataInterface extends MetadataInterface\r\n{\r\n&nbsp;&nbsp;&nbsp;const ATTRIBUTE_SET_ID_ADDRESS = 2;\r\n&nbsp;&nbsp;&nbsp;const ENTITY_TYPE_ADDRESS = 'customer_address';\r\n&nbsp;&nbsp;&nbsp;const DATA_INTERFACE_NAME = \\Magento\\Customer\\Api\\Data\\AddressInterface::class;\r\n}<\/pre>\n<p>Service layer is not mandatory, however, Magento developers recommend it for developing your modules. Magento developers plan to convert all their internal modules to using this layer. Its usage leads to a slight loss of productivity, which is insignificant compared to the advantages of this approach.<\/p>\n\n","protected":false},"excerpt":{"rendered":"Magento 2 architecture description","protected":false},"author":82,"featured_media":15693,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"image","meta":{"_acf_changed":false,"footnotes":""},"categories":[474,389,524],"tags":[],"class_list":["post-15644","post","type-post","status-publish","format-image","has-post-thumbnail","hentry","category-ecommerce","category-magento2-development","category-magento-speed-optimization","post_format-post-format-image"],"acf":[],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.4 - aioseo.com -->\n\t<meta name=\"description\" content=\"A detailed description of each of the 4 layers in Magento 2 architecture: presentation, service, domain and persistence layers.\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Andrey Litvin\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/belvg.com\/blog\/magento-2-architecture-how-is-it-used-in-magento-2-application.html\" \/>\n\t\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.4\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/magento-2-architecture-how-is-it-used-in-magento-2-application.html#article\",\"name\":\"Describing the Layers of Magento 2 Architecture | BelVG Blog\",\"headline\":\"Magento 2 Architecture. Service Layer\",\"author\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/andrey-litvin#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#organization\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/wp-content\\\/uploads\\\/2018\\\/04\\\/Architecture_in_Magento_2_What_Is-3.jpg\",\"width\":770,\"height\":433},\"datePublished\":\"2018-04-26T15:53:45+02:00\",\"dateModified\":\"2021-02-18T14:03:30+02:00\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/magento-2-architecture-how-is-it-used-in-magento-2-application.html#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/magento-2-architecture-how-is-it-used-in-magento-2-application.html#webpage\"},\"articleSection\":\"ECOMMERCE, Magento 2 Development, Magento Speed Optimization, Image\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/magento-2-architecture-how-is-it-used-in-magento-2-application.html#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/belvg.com\\\/blog\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/category\\\/magento2-development#listItem\",\"name\":\"Magento 2 Development\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/category\\\/magento2-development#listItem\",\"position\":2,\"name\":\"Magento 2 Development\",\"item\":\"https:\\\/\\\/belvg.com\\\/blog\\\/category\\\/magento2-development\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/magento-2-architecture-how-is-it-used-in-magento-2-application.html#listItem\",\"name\":\"Magento 2 Architecture. Service Layer\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/magento-2-architecture-how-is-it-used-in-magento-2-application.html#listItem\",\"position\":3,\"name\":\"Magento 2 Architecture. Service Layer\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/category\\\/magento2-development#listItem\",\"name\":\"Magento 2 Development\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#organization\",\"name\":\"BelVG Blog\",\"description\":\"Magento and Prestashop articles\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/andrey-litvin#author\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/andrey-litvin\",\"name\":\"Andrey Litvin\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/magento-2-architecture-how-is-it-used-in-magento-2-application.html#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/e1a6e3c80cb940fddb65016d94b015cd951b4a8a9cd7227565131f28ea95c7a0?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"Andrey Litvin\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/magento-2-architecture-how-is-it-used-in-magento-2-application.html#webpage\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/magento-2-architecture-how-is-it-used-in-magento-2-application.html\",\"name\":\"Describing the Layers of Magento 2 Architecture | BelVG Blog\",\"description\":\"A detailed description of each of the 4 layers in Magento 2 architecture: presentation, service, domain and persistence layers.\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/magento-2-architecture-how-is-it-used-in-magento-2-application.html#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/andrey-litvin#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/andrey-litvin#author\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/wp-content\\\/uploads\\\/2018\\\/04\\\/Architecture_in_Magento_2_What_Is-3.jpg\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/magento-2-architecture-how-is-it-used-in-magento-2-application.html\\\/#mainImage\",\"width\":770,\"height\":433},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/magento-2-architecture-how-is-it-used-in-magento-2-application.html#mainImage\"},\"datePublished\":\"2018-04-26T15:53:45+02:00\",\"dateModified\":\"2021-02-18T14:03:30+02:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/\",\"name\":\"BelVG Blog\",\"description\":\"Magento and Prestashop articles\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Describing the Layers of Magento 2 Architecture | BelVG Blog","description":"A detailed description of each of the 4 layers in Magento 2 architecture: presentation, service, domain and persistence layers.","canonical_url":"https:\/\/belvg.com\/blog\/magento-2-architecture-how-is-it-used-in-magento-2-application.html","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/belvg.com\/blog\/magento-2-architecture-how-is-it-used-in-magento-2-application.html#article","name":"Describing the Layers of Magento 2 Architecture | BelVG Blog","headline":"Magento 2 Architecture. Service Layer","author":{"@id":"https:\/\/belvg.com\/blog\/author\/andrey-litvin#author"},"publisher":{"@id":"https:\/\/belvg.com\/blog\/#organization"},"image":{"@type":"ImageObject","url":"https:\/\/belvg.com\/blog\/wp-content\/uploads\/2018\/04\/Architecture_in_Magento_2_What_Is-3.jpg","width":770,"height":433},"datePublished":"2018-04-26T15:53:45+02:00","dateModified":"2021-02-18T14:03:30+02:00","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/belvg.com\/blog\/magento-2-architecture-how-is-it-used-in-magento-2-application.html#webpage"},"isPartOf":{"@id":"https:\/\/belvg.com\/blog\/magento-2-architecture-how-is-it-used-in-magento-2-application.html#webpage"},"articleSection":"ECOMMERCE, Magento 2 Development, Magento Speed Optimization, Image"},{"@type":"BreadcrumbList","@id":"https:\/\/belvg.com\/blog\/magento-2-architecture-how-is-it-used-in-magento-2-application.html#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/#listItem","position":1,"name":"Home","item":"https:\/\/belvg.com\/blog\/","nextItem":{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/category\/magento2-development#listItem","name":"Magento 2 Development"}},{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/category\/magento2-development#listItem","position":2,"name":"Magento 2 Development","item":"https:\/\/belvg.com\/blog\/category\/magento2-development","nextItem":{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/magento-2-architecture-how-is-it-used-in-magento-2-application.html#listItem","name":"Magento 2 Architecture. Service Layer"},"previousItem":{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/magento-2-architecture-how-is-it-used-in-magento-2-application.html#listItem","position":3,"name":"Magento 2 Architecture. Service Layer","previousItem":{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/category\/magento2-development#listItem","name":"Magento 2 Development"}}]},{"@type":"Organization","@id":"https:\/\/belvg.com\/blog\/#organization","name":"BelVG Blog","description":"Magento and Prestashop articles","url":"https:\/\/belvg.com\/blog\/"},{"@type":"Person","@id":"https:\/\/belvg.com\/blog\/author\/andrey-litvin#author","url":"https:\/\/belvg.com\/blog\/author\/andrey-litvin","name":"Andrey Litvin","image":{"@type":"ImageObject","@id":"https:\/\/belvg.com\/blog\/magento-2-architecture-how-is-it-used-in-magento-2-application.html#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/e1a6e3c80cb940fddb65016d94b015cd951b4a8a9cd7227565131f28ea95c7a0?s=96&d=mm&r=g","width":96,"height":96,"caption":"Andrey Litvin"}},{"@type":"WebPage","@id":"https:\/\/belvg.com\/blog\/magento-2-architecture-how-is-it-used-in-magento-2-application.html#webpage","url":"https:\/\/belvg.com\/blog\/magento-2-architecture-how-is-it-used-in-magento-2-application.html","name":"Describing the Layers of Magento 2 Architecture | BelVG Blog","description":"A detailed description of each of the 4 layers in Magento 2 architecture: presentation, service, domain and persistence layers.","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/belvg.com\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/belvg.com\/blog\/magento-2-architecture-how-is-it-used-in-magento-2-application.html#breadcrumblist"},"author":{"@id":"https:\/\/belvg.com\/blog\/author\/andrey-litvin#author"},"creator":{"@id":"https:\/\/belvg.com\/blog\/author\/andrey-litvin#author"},"image":{"@type":"ImageObject","url":"https:\/\/belvg.com\/blog\/wp-content\/uploads\/2018\/04\/Architecture_in_Magento_2_What_Is-3.jpg","@id":"https:\/\/belvg.com\/blog\/magento-2-architecture-how-is-it-used-in-magento-2-application.html\/#mainImage","width":770,"height":433},"primaryImageOfPage":{"@id":"https:\/\/belvg.com\/blog\/magento-2-architecture-how-is-it-used-in-magento-2-application.html#mainImage"},"datePublished":"2018-04-26T15:53:45+02:00","dateModified":"2021-02-18T14:03:30+02:00"},{"@type":"WebSite","@id":"https:\/\/belvg.com\/blog\/#website","url":"https:\/\/belvg.com\/blog\/","name":"BelVG Blog","description":"Magento and Prestashop articles","inLanguage":"en-US","publisher":{"@id":"https:\/\/belvg.com\/blog\/#organization"}}]}},"aioseo_meta_data":{"post_id":"15644","title":"Describing the Layers of Magento 2 Architecture | #site_title","description":"A detailed description of each of the 4 layers in Magento 2 architecture: presentation, service, domain and persistence layers.","keywords":null,"keyphrases":null,"focus_keyword":null,"additional_keywords":null,"truseo_locale":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_custom_url":null,"og_image_custom_fields":null,"og_image_url":null,"og_image_width":null,"og_image_height":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_image_url":null,"twitter_title":null,"twitter_description":null,"schema_type":"default","schema_type_options":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"limit_modified_date":false,"ai":null,"breadcrumb_settings":null,"seo_analyzer_scan_date":null,"created":"2026-11-03 18:37:09","updated":"2026-11-03 18:37:09"},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/belvg.com\/blog\/\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/belvg.com\/blog\/category\/magento2-development\" title=\"Magento 2 Development\">Magento 2 Development<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tMagento 2 Architecture. Service Layer\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/belvg.com\/blog\/"},{"label":"Magento 2 Development","link":"https:\/\/belvg.com\/blog\/category\/magento2-development"},{"label":"Magento 2 Architecture. Service Layer","link":"https:\/\/belvg.com\/blog\/magento-2-architecture-how-is-it-used-in-magento-2-application.html"}],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/posts\/15644","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/users\/82"}],"replies":[{"embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/comments?post=15644"}],"version-history":[{"count":7,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/posts\/15644\/revisions"}],"predecessor-version":[{"id":23567,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/posts\/15644\/revisions\/23567"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/media\/15693"}],"wp:attachment":[{"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/media?parent=15644"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/categories?post=15644"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/tags?post=15644"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}