{"id":4825,"date":"2023-07-21T00:34:00","date_gmt":"2023-07-20T23:34:00","guid":{"rendered":"https:\/\/www.utilewebsites.nl\/knowledgebase\/the-structure-of-a-custom-module-in-magento-2-structure-and-terminology\/"},"modified":"2023-09-22T00:38:39","modified_gmt":"2023-09-21T23:38:39","slug":"the-structure-of-a-custom-module-in-magento-2-structure-and-terminology","status":"publish","type":"wz_knowledgebase","link":"https:\/\/www.utilewebsites.nl\/en\/knowledgebase\/the-structure-of-a-custom-module-in-magento-2-structure-and-terminology\/","title":{"rendered":"The Structure of a Custom Module in Magento 2: Structure and Terminology"},"content":{"rendered":"\n<p>Magento 2 is known as a robust e-commerce platform that supports custom modules. These modules allow users to personalize and expand their online stores according to specific needs. This article highlights the core aspects of building a custom module in Magento 2, with specific focus on structure and terminology.<\/p>\n\n<p><strong>What is a Custom Module in Magento 2?<\/strong><\/p>\n\n<p>A custom module within Magento 2 is a package of code that provides additional functionality to your e-commerce website. Depending on the need, this can range from minor tweaks to extensive additions. Modules provide seamless expansion of Magento 2 core functionality without direct changes to core code, facilitating upgrades and maintenance.<\/p>\n\n<p><strong>Structure of a Magento 2 Custom Module<\/strong><\/p>\n\n<p>Each Magento 2 custom module has a standardized and well-considered structure. Below is a list of the main folders and their functions:<\/p>\n\n<ul class=\"wp-block-list\">\n<li><strong>etc:<\/strong> This folder contains configuration files that define routes, models, blocks, observers and cron tasks.<\/li>\n\n\n\n<li><strong>Block:<\/strong> Here are the ViewModels for the front-end, essential for data presentation.<\/li>\n\n\n\n<li><strong>Controller:<\/strong> This folder houses controllers that control the interaction between the user and the module.<\/li>\n\n\n\n<li><strong>Model:<\/strong> Here you will find Models and ResourceModels, which are the core of the module's business logic.<\/li>\n\n\n\n<li><strong>Observer:<\/strong> Observers \"observe\" system events and respond to them.<\/li>\n\n\n\n<li><strong>Setup:<\/strong> Responsible for database schedules and changes to them.<\/li>\n\n\n\n<li><strong>Ui:<\/strong> For UI elements such as grids and forms in the management interface.<\/li>\n\n\n\n<li><strong>view:<\/strong> Contains layout and template files for both front-end and management interface.<\/li>\n\n\n\n<li><strong>i18n:<\/strong> For international support through translations.<\/li>\n\n\n\n<li><strong>Helper:<\/strong> Utilities and classes used in multiple layers of the application.<\/li>\n\n\n\n<li><strong>Test:<\/strong> Here you can write tests for your module to verify operation.<\/li>\n<\/ul>\n\n<p><strong>Composer and External Dependencies<\/strong><\/p>\n\n<p>Magento 2 integrates with Composer, PHP's dependency manager, for managing external dependencies. This facilitates the integration of external libraries such as Zend Framework and Symfony.<\/p>\n\n<p><strong>Conclusion<\/strong><\/p>\n\n<p>Developing a custom module in Magento 2 requires an understanding of the underlying structure and terminology. Thanks to the standardized layout, modules are easy to manage and expand. By leveraging Composer, external resources can be seamlessly integrated. This allows you to unlock the full potential of Magento 2 and optimize your online business.<\/p>\n\n<p><strong>Additional note:<\/strong> Magento 2's Community Edition (CE) and Enterprise Edition (EE) both build on the same core of Magento 2, meaning they share many common functionalities. Therefore, modules developed specifically for the CE version are usually also usable within the EE version without problems.<\/p>\n\n<p><strong>Directory Tree of a Typical Magento 2 Module<\/strong><\/p>\n\n<pre class=\"wp-block-code\"><code>Magento_ExampleModule\/\n\u2502\n\u251c\u2500\u2500 etc\/\n\u2502   \u251c\u2500\u2500 module.xml\n\u2502   \u251c\u2500\u2500 adminhtml\/\n\u2502   \u2502   \u2514\u2500\u2500 system.xml\n\u2502   \u2514\u2500\u2500 frontend\/\n\u2502       \u2514\u2500\u2500 routes.xml\n\u2502\n\u251c\u2500\u2500 Block\/\n\u2502   \u251c\u2500\u2500 Adminhtml\/\n\u2502   \u2502   \u2514\u2500\u2500 BlockFile.php\n\u2502   \u2514\u2500\u2500 Frontend\/\n\u2502       \u2514\u2500\u2500 BlockFile.php\n\u2502\n\u251c\u2500\u2500 Controller\/\n\u2502   \u251c\u2500\u2500 Adminhtml\/\n\u2502   \u2502   \u2514\u2500\u2500 ControllerFile.php\n\u2502   \u2514\u2500\u2500 Frontend\/\n\u2502       \u2514\u2500\u2500 ControllerFile.php\n\u2502\n\u251c\u2500\u2500 Model\/\n\u2502   \u251c\u2500\u2500 ModelFile.php\n\u2502   \u2514\u2500\u2500 ResourceModel\/\n\u2502       \u2514\u2500\u2500 ResourceFile.php\n\u2502\n\u251c\u2500\u2500 Observer\/\n\u2502   \u2514\u2500\u2500 ObserverFile.php\n\u2502\n\u251c\u2500\u2500 Setup\/\n\u2502   \u2514\u2500\u2500 InstallSchema.php\n\u2502\n\u251c\u2500\u2500 Ui\/\n\u2502   \u251c\u2500\u2500 Component\/\n\u2502   \u2502   \u2514\u2500\u2500 Listing\/\n\u2502   \u2502       \u2514\u2500\u2500 Column\/\n\u2502   \u2502           \u2514\u2500\u2500 ColumnFile.php\n\u2502   \u2514\u2500\u2500 DataProvider\/\n\u2502       \u2514\u2500\u2500 DataFile.php\n\u2502\n\u251c\u2500\u2500 view\/\n\u2502   \u251c\u2500\u2500 adminhtml\/\n\u2502   \u2502   \u2514\u2500\u2500 ui_component\/\n\u2502   \u2502       \u2514\u2500\u2500 examplemodule_form.xml\n\u2502   \u2514\u2500\u2500 frontend\/\n\u2502       \u251c\u2500\u2500 layout\/\n\u2502       \u2502   \u2514\u2500\u2500 examplemodule_index_index.xml\n\u2502       \u2514\u2500\u2500 templates\/\n\u2502           \u2514\u2500\u2500 templatefile.phtml\n\u2502\n\u251c\u2500\u2500 i18n\/\n\u2502   \u2514\u2500\u2500 en_US.csv\n\u2502\n\u251c\u2500\u2500 Helper\/\n\u2502   \u2514\u2500\u2500 Data.php\n\u2502\n\u2514\u2500\u2500 Test\/\n    \u2514\u2500\u2500 Unit\/\n        \u2514\u2500\u2500 Model\/\n            \u2514\u2500\u2500 ModelTest.php\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Magento 2 is known as a robust e-commerce platform that supports custom modules. These modules allow users to personalize and expand their online stores according to specific needs. This article highlights the core aspects of building a custom module in Magento 2, with specific focus on structure and terminology. What is a Custom Module in Magento 2? A custom module within Magento 2 is a package of code that provides additional functionality to your e-commerce website. Depending on the need, this can range from minor tweaks to extensive additions. Modules provide seamless expansion of Magento 2 core functionality without direct&nbsp;<a href=\"https:\/\/www.utilewebsites.nl\/en\/knowledgebase\/the-structure-of-a-custom-module-in-magento-2-structure-and-terminology\/\" class=\"read-more\">Continue Reading<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"wzkb_category":[61],"wzkb_tag":[],"class_list":["post-4825","wz_knowledgebase","type-wz_knowledgebase","status-publish","hentry","wzkb_category-magento-2-0-x"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>The Structure of a Custom Module in Magento 2: Structure and Terminology - Utilewebsites<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.utilewebsites.nl\/en\/knowledgebase\/the-structure-of-a-custom-module-in-magento-2-structure-and-terminology\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"The Structure of a Custom Module in Magento 2: Structure and Terminology - Utilewebsites\" \/>\n<meta property=\"og:description\" content=\"Magento 2 is known as a robust e-commerce platform that supports custom modules. These modules allow users to personalize and expand their online stores according to specific needs. This article highlights the core aspects of building a custom module in Magento 2, with specific focus on structure and terminology. What is a Custom Module in Magento 2? A custom module within Magento 2 is a package of code that provides additional functionality to your e-commerce website. Depending on the need, this can range from minor tweaks to extensive additions. Modules provide seamless expansion of Magento 2 core functionality without direct&nbsp;Continue Reading\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.utilewebsites.nl\/en\/knowledgebase\/the-structure-of-a-custom-module-in-magento-2-structure-and-terminology\/\" \/>\n<meta property=\"og:site_name\" content=\"Utilewebsites\" \/>\n<meta property=\"article:modified_time\" content=\"2023-09-21T23:38:39+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/knowledgebase\\\/the-structure-of-a-custom-module-in-magento-2-structure-and-terminology\\\/\",\"url\":\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/knowledgebase\\\/the-structure-of-a-custom-module-in-magento-2-structure-and-terminology\\\/\",\"name\":\"The Structure of a Custom Module in Magento 2: Structure and Terminology - Utilewebsites\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/#website\"},\"datePublished\":\"2023-07-20T23:34:00+00:00\",\"dateModified\":\"2023-09-21T23:38:39+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/knowledgebase\\\/the-structure-of-a-custom-module-in-magento-2-structure-and-terminology\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/knowledgebase\\\/the-structure-of-a-custom-module-in-magento-2-structure-and-terminology\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/knowledgebase\\\/the-structure-of-a-custom-module-in-magento-2-structure-and-terminology\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Knowledge Base\",\"item\":\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/knowledgebase\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"The Structure of a Custom Module in Magento 2: Structure and Terminology\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/#website\",\"url\":\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/\",\"name\":\"Utilewebsites\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/#organization\",\"name\":\"Utilewebsites\",\"url\":\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.utilewebsites.nl\\\/wp-content\\\/uploads\\\/2019\\\/08\\\/logo-Utilewebsites-2017.png\",\"contentUrl\":\"https:\\\/\\\/www.utilewebsites.nl\\\/wp-content\\\/uploads\\\/2019\\\/08\\\/logo-Utilewebsites-2017.png\",\"width\":3000,\"height\":593,\"caption\":\"Utilewebsites\"},\"image\":{\"@id\":\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/#\\\/schema\\\/logo\\\/image\\\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"The Structure of a Custom Module in Magento 2: Structure and Terminology - Utilewebsites","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.utilewebsites.nl\/en\/knowledgebase\/the-structure-of-a-custom-module-in-magento-2-structure-and-terminology\/","og_locale":"en_US","og_type":"article","og_title":"The Structure of a Custom Module in Magento 2: Structure and Terminology - Utilewebsites","og_description":"Magento 2 is known as a robust e-commerce platform that supports custom modules. These modules allow users to personalize and expand their online stores according to specific needs. This article highlights the core aspects of building a custom module in Magento 2, with specific focus on structure and terminology. What is a Custom Module in Magento 2? A custom module within Magento 2 is a package of code that provides additional functionality to your e-commerce website. Depending on the need, this can range from minor tweaks to extensive additions. Modules provide seamless expansion of Magento 2 core functionality without direct&nbsp;Continue Reading","og_url":"https:\/\/www.utilewebsites.nl\/en\/knowledgebase\/the-structure-of-a-custom-module-in-magento-2-structure-and-terminology\/","og_site_name":"Utilewebsites","article_modified_time":"2023-09-21T23:38:39+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.utilewebsites.nl\/en\/knowledgebase\/the-structure-of-a-custom-module-in-magento-2-structure-and-terminology\/","url":"https:\/\/www.utilewebsites.nl\/en\/knowledgebase\/the-structure-of-a-custom-module-in-magento-2-structure-and-terminology\/","name":"The Structure of a Custom Module in Magento 2: Structure and Terminology - Utilewebsites","isPartOf":{"@id":"https:\/\/www.utilewebsites.nl\/en\/#website"},"datePublished":"2023-07-20T23:34:00+00:00","dateModified":"2023-09-21T23:38:39+00:00","breadcrumb":{"@id":"https:\/\/www.utilewebsites.nl\/en\/knowledgebase\/the-structure-of-a-custom-module-in-magento-2-structure-and-terminology\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.utilewebsites.nl\/en\/knowledgebase\/the-structure-of-a-custom-module-in-magento-2-structure-and-terminology\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.utilewebsites.nl\/en\/knowledgebase\/the-structure-of-a-custom-module-in-magento-2-structure-and-terminology\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.utilewebsites.nl\/en\/"},{"@type":"ListItem","position":2,"name":"Knowledge Base","item":"https:\/\/www.utilewebsites.nl\/en\/knowledgebase\/"},{"@type":"ListItem","position":3,"name":"The Structure of a Custom Module in Magento 2: Structure and Terminology"}]},{"@type":"WebSite","@id":"https:\/\/www.utilewebsites.nl\/en\/#website","url":"https:\/\/www.utilewebsites.nl\/en\/","name":"Utilewebsites","description":"","publisher":{"@id":"https:\/\/www.utilewebsites.nl\/en\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.utilewebsites.nl\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.utilewebsites.nl\/en\/#organization","name":"Utilewebsites","url":"https:\/\/www.utilewebsites.nl\/en\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.utilewebsites.nl\/en\/#\/schema\/logo\/image\/","url":"https:\/\/www.utilewebsites.nl\/wp-content\/uploads\/2019\/08\/logo-Utilewebsites-2017.png","contentUrl":"https:\/\/www.utilewebsites.nl\/wp-content\/uploads\/2019\/08\/logo-Utilewebsites-2017.png","width":3000,"height":593,"caption":"Utilewebsites"},"image":{"@id":"https:\/\/www.utilewebsites.nl\/en\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/www.utilewebsites.nl\/en\/wp-json\/wp\/v2\/wz_knowledgebase\/4825","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.utilewebsites.nl\/en\/wp-json\/wp\/v2\/wz_knowledgebase"}],"about":[{"href":"https:\/\/www.utilewebsites.nl\/en\/wp-json\/wp\/v2\/types\/wz_knowledgebase"}],"author":[{"embeddable":true,"href":"https:\/\/www.utilewebsites.nl\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.utilewebsites.nl\/en\/wp-json\/wp\/v2\/comments?post=4825"}],"version-history":[{"count":3,"href":"https:\/\/www.utilewebsites.nl\/en\/wp-json\/wp\/v2\/wz_knowledgebase\/4825\/revisions"}],"predecessor-version":[{"id":4828,"href":"https:\/\/www.utilewebsites.nl\/en\/wp-json\/wp\/v2\/wz_knowledgebase\/4825\/revisions\/4828"}],"wp:attachment":[{"href":"https:\/\/www.utilewebsites.nl\/en\/wp-json\/wp\/v2\/media?parent=4825"}],"wp:term":[{"taxonomy":"wzkb_category","embeddable":true,"href":"https:\/\/www.utilewebsites.nl\/en\/wp-json\/wp\/v2\/wzkb_category?post=4825"},{"taxonomy":"wzkb_tag","embeddable":true,"href":"https:\/\/www.utilewebsites.nl\/en\/wp-json\/wp\/v2\/wzkb_tag?post=4825"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}