{"id":8128,"date":"2013-03-08T13:23:24","date_gmt":"2013-03-08T07:53:24","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=8128"},"modified":"2016-12-19T14:50:34","modified_gmt":"2016-12-19T09:20:34","slug":"magento-mvc-architecture-flow","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/magento-mvc-architecture-flow\/","title":{"rendered":"Magento MVC Architecture &amp; Flow"},"content":{"rendered":"<p>There are many systems in PHP that follows MVC\u00a0 (Model-View-Controller) architecture.\u00a0\u00a0 It is a robust design pattern that separates data access, business logic and user interface code.<\/p>\n<p>A typical MVC concept,<\/p>\n<p><strong> <\/strong><\/p>\n<p><strong>Model:<\/strong> consists of application data and business rules.\u00a0 It communicates with the database get the information. In Magento, we have these files under \u201cModel\u201d folder of each module in any code pool be it core, local or community.<\/p>\n<p><strong>Controller:<\/strong> mediates input, converting it to commands for the model. These files decides action between model and view files. They can be found under \u201ccontrollers\u201d folder of each module in core, local or community code pool.<\/p>\n<p><strong>View:<\/strong> output representation of data like rendered HTML. In Magento, these files resides under template at app\/design and have .phtml extension. These files have combination of PHP and HTML code as well as $this object to refer to Model for data structure.<\/p>\n<p>But Magento is based on more abstract MVC\u00a0 pattern. Refer the below diagram<\/p>\n<p><strong>Description:<\/strong><\/p>\n<ol>\n<li>URL is taken by a single PHP file and Magento application is instantiated<\/li>\n<li>Application instantiate Front Controller Object<\/li>\n<li>Front Controller instantiate Routers<\/li>\n<li>Routers check URL and determines Controller and Actions<\/li>\n<li>Action Methods manipulate Models<\/li>\n<li>Action loads layout and kicks off rendering<\/li>\n<li>Templates, via Blocks, read from Models<\/li>\n<li>Blocks and Child Blocks render into HTML page<\/li>\n<\/ol>\n<p><strong>Note:<\/strong> Unlike other MVC patters, Magento Blocks refer to the Models for their data as Action Controller does not pass them data structure.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There are many systems in PHP that follows MVC\u00a0 (Model-View-Controller) architecture.\u00a0\u00a0 It is a robust design pattern that separates data access, business logic and user interface code. A typical MVC concept, Model: consists of application data and business rules.\u00a0 It communicates with the database get the information. In Magento, we have these files under \u201cModel\u201d [&hellip;]<\/p>\n","protected":false},"author":59,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":4},"categories":[1],"tags":[1040,1038,1039],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/8128"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/59"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=8128"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/8128\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=8128"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=8128"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=8128"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}