SlideShare a Scribd company logo
1 of 14
How to create a module in Magento 2.0
(Updated in August 2015)
2
1 THE STRUCTURE OF A SIMPLE MODULE
Magento 1 vs Magento 2
Some new folders in Magento 2
2
CREATE A SIMPLE MODULE IN MAGENTO 2
Step 1: Create configuration files
Step 2: Create controller, layout and template files
Step 3: Activate the module in the configuration file
OUTLINE
MAGENTO 2
Folders and files of a module are put in
only a package and located in app/code
folder
1. THE STRUCTURE OF A SIMPLE MODULE
MAGENTO 1
Folders and files of a module are located
in different folders: app/code/local,
app/code/community, app/design,
app/etc, app/locale, js, skin,…
Some new folders in Magento 2
i18n: store the .csv files for module
translator. Eg: en_US.csv, de_DE.csv
Setup: store the files which are used to
create tables or insert data to the
database.
View: This folder stores the layout,
template, image, CSS and Javascript
files which are used for your module.
Let’s create folders with the structure as
following:
Namespace: Tutorial
Module name: Example
Example link on Local host:
http://localhost/magento2/exam
ple/index/index/
2. CREATE A SIMPLE MODULE IN MAGENTO 2
Step 1: Create configuration files
1.1. Create file: app/code/Tutorial/Example/etc/module.xml
Purpose: Declare your module
Source Code:
(Go to our blog tutorial for full source code)
Step 1: Create configuration files
1.2 Create file:
app/code/Tutorial/Example/etc/frontend/routes.xml
Purpose: Declare the router of module for frontend
(Go to our blog tutorial for full source code)
Step 2: Create controller, layout and template files
2.1 Create the controller
file: app/code/Tutorial/Example/Controller/Index/Index.php
=> The souce code is found in our blog tutorial
Step 2: Create controller, layout and template files
2.2 Create the layout file:
app/code/Tutorial/Example/view/frontend/layout/example_inde
x_index.xml
(Go to our blog tutorial for full source code)
Step 2: Create controller, layout and template files
2.3 Create the template file:
app/code/Tutorial/Example/view/frontend/templates/index.phtml
(Go to our blog tutorial for full source code)
Step 3: Activate the module in the configuration file
3.1 Activate module by opening app/etc/config.php file then
add this line “'Tutorial_Example' => 1” into it:
(Go to our blog tutorial for full source code)
Step 3: Activate the module in the configuration file
3.2 Open the Command in Windows (or the Terminal in Linux
and MAC OS). Go to Magento root folder and run this
command line to install module:
binmagento setup:upgrade
(Go to our blog tutorial for full source code)
Step 3: Activate the module in the configuration file
3.3 Clear the Magento cache then access with
url http://localhost/magento2/example/index/index/
Following MageWorld Magento 2 Tutorial Series…

More Related Content

Viewers also liked

Presentatie taskforce social op Interact 2010 deel1
Presentatie taskforce social op Interact 2010 deel1Presentatie taskforce social op Interact 2010 deel1
Presentatie taskforce social op Interact 2010 deel1John Meulemans
 
Comm final project
Comm final projectComm final project
Comm final projectdavidtrotto
 
Png还是jpg,这是个问题
Png还是jpg,这是个问题Png还是jpg,这是个问题
Png还是jpg,这是个问题碳酸饮料会
 
Fundusze inwestycyjne
Fundusze inwestycyjneFundusze inwestycyjne
Fundusze inwestycyjneGucio Silva
 
237-Vineyards-comptine
237-Vineyards-comptine237-Vineyards-comptine
237-Vineyards-comptinemireille 30100
 
Models by Percent Discount
Models by Percent DiscountModels by Percent Discount
Models by Percent DiscountTrueCar
 
2011 Toyota Highlnder Plano
2011 Toyota Highlnder Plano2011 Toyota Highlnder Plano
2011 Toyota Highlnder PlanoToyota of Irving
 
Peter Crosby - Levelling the Playing Field: Social Recruitment & Professional...
Peter Crosby - Levelling the Playing Field: Social Recruitment & Professional...Peter Crosby - Levelling the Playing Field: Social Recruitment & Professional...
Peter Crosby - Levelling the Playing Field: Social Recruitment & Professional...Viadeo
 
Social Media: Which to? How to? Why to?
Social Media: Which to? How to? Why to?Social Media: Which to? How to? Why to?
Social Media: Which to? How to? Why to?Auctori
 
Blog her devries_surveyfinal, ec
Blog her devries_surveyfinal, ecBlog her devries_surveyfinal, ec
Blog her devries_surveyfinal, ecElisa Camahort Page
 
Central Banks Macro Adjustments
Central Banks Macro AdjustmentsCentral Banks Macro Adjustments
Central Banks Macro AdjustmentsRod Medallon
 
Communique -- May 2010
Communique -- May 2010Communique -- May 2010
Communique -- May 2010HexagonCapital
 
Rrb po-clerk-capsule-2015
Rrb po-clerk-capsule-2015Rrb po-clerk-capsule-2015
Rrb po-clerk-capsule-2015ashkhare23
 

Viewers also liked (18)

Presentatie taskforce social op Interact 2010 deel1
Presentatie taskforce social op Interact 2010 deel1Presentatie taskforce social op Interact 2010 deel1
Presentatie taskforce social op Interact 2010 deel1
 
Comm final project
Comm final projectComm final project
Comm final project
 
Faq
FaqFaq
Faq
 
Svadebnaya masterskaya
Svadebnaya masterskayaSvadebnaya masterskaya
Svadebnaya masterskaya
 
Png还是jpg,这是个问题
Png还是jpg,这是个问题Png还是jpg,这是个问题
Png还是jpg,这是个问题
 
Fundusze inwestycyjne
Fundusze inwestycyjneFundusze inwestycyjne
Fundusze inwestycyjne
 
Presentation1
Presentation1Presentation1
Presentation1
 
237-Vineyards-comptine
237-Vineyards-comptine237-Vineyards-comptine
237-Vineyards-comptine
 
Models by Percent Discount
Models by Percent DiscountModels by Percent Discount
Models by Percent Discount
 
2011 Toyota Corolla Plano
2011 Toyota Corolla Plano2011 Toyota Corolla Plano
2011 Toyota Corolla Plano
 
2011 Toyota Highlnder Plano
2011 Toyota Highlnder Plano2011 Toyota Highlnder Plano
2011 Toyota Highlnder Plano
 
Peter Crosby - Levelling the Playing Field: Social Recruitment & Professional...
Peter Crosby - Levelling the Playing Field: Social Recruitment & Professional...Peter Crosby - Levelling the Playing Field: Social Recruitment & Professional...
Peter Crosby - Levelling the Playing Field: Social Recruitment & Professional...
 
Social Media: Which to? How to? Why to?
Social Media: Which to? How to? Why to?Social Media: Which to? How to? Why to?
Social Media: Which to? How to? Why to?
 
Awesome images
Awesome imagesAwesome images
Awesome images
 
Blog her devries_surveyfinal, ec
Blog her devries_surveyfinal, ecBlog her devries_surveyfinal, ec
Blog her devries_surveyfinal, ec
 
Central Banks Macro Adjustments
Central Banks Macro AdjustmentsCentral Banks Macro Adjustments
Central Banks Macro Adjustments
 
Communique -- May 2010
Communique -- May 2010Communique -- May 2010
Communique -- May 2010
 
Rrb po-clerk-capsule-2015
Rrb po-clerk-capsule-2015Rrb po-clerk-capsule-2015
Rrb po-clerk-capsule-2015
 

Similar to How to create a simple module in Magento 2.0

Federico Soich - Upgrading Magento Version
Federico Soich - Upgrading Magento VersionFederico Soich - Upgrading Magento Version
Federico Soich - Upgrading Magento VersionMeet Magento Italy
 
M2ModuleDevelopmenteBook
M2ModuleDevelopmenteBookM2ModuleDevelopmenteBook
M2ModuleDevelopmenteBookTrọng Huỳnh
 
How To Create Theme in Magento 2 - Part 1
How To Create Theme in Magento 2 - Part 1How To Create Theme in Magento 2 - Part 1
How To Create Theme in Magento 2 - Part 1Magestore
 
How to create theme in Magento 2 - Part 2
How to create theme in Magento 2 - Part 2How to create theme in Magento 2 - Part 2
How to create theme in Magento 2 - Part 2Magestore
 
Mageguru - magento custom module development
Mageguru -  magento custom module development Mageguru -  magento custom module development
Mageguru - magento custom module development Mage Guru
 
Tips On Trick Odoo Add-On.pptx
Tips On Trick Odoo Add-On.pptxTips On Trick Odoo Add-On.pptx
Tips On Trick Odoo Add-On.pptxAgusto Sipahutar
 
Madison PHP - Getting Started with Magento 2
Madison PHP - Getting Started with Magento 2Madison PHP - Getting Started with Magento 2
Madison PHP - Getting Started with Magento 2Mathew Beane
 
Struts2 tutorial
Struts2 tutorialStruts2 tutorial
Struts2 tutorializdihara
 
Create Basic module in magento2| Tuitorial hello world Magento2
Create Basic module in magento2| Tuitorial hello world Magento2Create Basic module in magento2| Tuitorial hello world Magento2
Create Basic module in magento2| Tuitorial hello world Magento2eGlobe IT Solutions
 
Architecture and Analytical Study of Magento
Architecture and Analytical Study of MagentoArchitecture and Analytical Study of Magento
Architecture and Analytical Study of MagentoIRJET Journal
 
Convert Magento 1 Extensions to Magento 2
Convert Magento 1 Extensions to Magento 2Convert Magento 1 Extensions to Magento 2
Convert Magento 1 Extensions to Magento 2Vladimir Kerkhoff
 
fuelOrigin.docx
fuelOrigin.docxfuelOrigin.docx
fuelOrigin.docxKanhaJi5
 
Introduction to Mangento
Introduction to Mangento Introduction to Mangento
Introduction to Mangento Ravi Mehrotra
 
Tips On Trick Odoo Add-On.pptx
Tips On Trick Odoo Add-On.pptxTips On Trick Odoo Add-On.pptx
Tips On Trick Odoo Add-On.pptxAgusto Sipahutar
 
CICON2010: Adam Griffiths - CodeIgniter 2
CICON2010: Adam Griffiths - CodeIgniter 2CICON2010: Adam Griffiths - CodeIgniter 2
CICON2010: Adam Griffiths - CodeIgniter 2CodeIgniter Conference
 

Similar to How to create a simple module in Magento 2.0 (20)

Federico Soich - Upgrading Magento Version
Federico Soich - Upgrading Magento VersionFederico Soich - Upgrading Magento Version
Federico Soich - Upgrading Magento Version
 
M2ModuleDevelopmenteBook
M2ModuleDevelopmenteBookM2ModuleDevelopmenteBook
M2ModuleDevelopmenteBook
 
How To Create Theme in Magento 2 - Part 1
How To Create Theme in Magento 2 - Part 1How To Create Theme in Magento 2 - Part 1
How To Create Theme in Magento 2 - Part 1
 
How to create theme in Magento 2 - Part 2
How to create theme in Magento 2 - Part 2How to create theme in Magento 2 - Part 2
How to create theme in Magento 2 - Part 2
 
Mageguru - magento custom module development
Mageguru -  magento custom module development Mageguru -  magento custom module development
Mageguru - magento custom module development
 
Tips On Trick Odoo Add-On.pptx
Tips On Trick Odoo Add-On.pptxTips On Trick Odoo Add-On.pptx
Tips On Trick Odoo Add-On.pptx
 
Madison PHP - Getting Started with Magento 2
Madison PHP - Getting Started with Magento 2Madison PHP - Getting Started with Magento 2
Madison PHP - Getting Started with Magento 2
 
12 Amazing Features of Magento 2
12 Amazing Features of Magento 212 Amazing Features of Magento 2
12 Amazing Features of Magento 2
 
Struts2 tutorial
Struts2 tutorialStruts2 tutorial
Struts2 tutorial
 
Struts2 tutorial
Struts2 tutorialStruts2 tutorial
Struts2 tutorial
 
Struts2 tutorial
Struts2 tutorialStruts2 tutorial
Struts2 tutorial
 
Create Basic module in magento2| Tuitorial hello world Magento2
Create Basic module in magento2| Tuitorial hello world Magento2Create Basic module in magento2| Tuitorial hello world Magento2
Create Basic module in magento2| Tuitorial hello world Magento2
 
Create basic hello world module in magento2
Create basic hello world module in magento2Create basic hello world module in magento2
Create basic hello world module in magento2
 
Architecture and Analytical Study of Magento
Architecture and Analytical Study of MagentoArchitecture and Analytical Study of Magento
Architecture and Analytical Study of Magento
 
Convert Magento 1 Extensions to Magento 2
Convert Magento 1 Extensions to Magento 2Convert Magento 1 Extensions to Magento 2
Convert Magento 1 Extensions to Magento 2
 
fuelOrigin.docx
fuelOrigin.docxfuelOrigin.docx
fuelOrigin.docx
 
Mangento
MangentoMangento
Mangento
 
Introduction to Mangento
Introduction to Mangento Introduction to Mangento
Introduction to Mangento
 
Tips On Trick Odoo Add-On.pptx
Tips On Trick Odoo Add-On.pptxTips On Trick Odoo Add-On.pptx
Tips On Trick Odoo Add-On.pptx
 
CICON2010: Adam Griffiths - CodeIgniter 2
CICON2010: Adam Griffiths - CodeIgniter 2CICON2010: Adam Griffiths - CodeIgniter 2
CICON2010: Adam Griffiths - CodeIgniter 2
 

Recently uploaded

Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningVitsRangannavar
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsMehedi Hasan Shohan
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 

Recently uploaded (20)

Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learning
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software Solutions
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 

How to create a simple module in Magento 2.0

  • 1. How to create a module in Magento 2.0 (Updated in August 2015) 2
  • 2. 1 THE STRUCTURE OF A SIMPLE MODULE Magento 1 vs Magento 2 Some new folders in Magento 2 2 CREATE A SIMPLE MODULE IN MAGENTO 2 Step 1: Create configuration files Step 2: Create controller, layout and template files Step 3: Activate the module in the configuration file OUTLINE
  • 3. MAGENTO 2 Folders and files of a module are put in only a package and located in app/code folder 1. THE STRUCTURE OF A SIMPLE MODULE MAGENTO 1 Folders and files of a module are located in different folders: app/code/local, app/code/community, app/design, app/etc, app/locale, js, skin,…
  • 4. Some new folders in Magento 2 i18n: store the .csv files for module translator. Eg: en_US.csv, de_DE.csv Setup: store the files which are used to create tables or insert data to the database. View: This folder stores the layout, template, image, CSS and Javascript files which are used for your module.
  • 5. Let’s create folders with the structure as following: Namespace: Tutorial Module name: Example Example link on Local host: http://localhost/magento2/exam ple/index/index/ 2. CREATE A SIMPLE MODULE IN MAGENTO 2
  • 6. Step 1: Create configuration files 1.1. Create file: app/code/Tutorial/Example/etc/module.xml Purpose: Declare your module Source Code: (Go to our blog tutorial for full source code)
  • 7. Step 1: Create configuration files 1.2 Create file: app/code/Tutorial/Example/etc/frontend/routes.xml Purpose: Declare the router of module for frontend (Go to our blog tutorial for full source code)
  • 8. Step 2: Create controller, layout and template files 2.1 Create the controller file: app/code/Tutorial/Example/Controller/Index/Index.php => The souce code is found in our blog tutorial
  • 9. Step 2: Create controller, layout and template files 2.2 Create the layout file: app/code/Tutorial/Example/view/frontend/layout/example_inde x_index.xml (Go to our blog tutorial for full source code)
  • 10. Step 2: Create controller, layout and template files 2.3 Create the template file: app/code/Tutorial/Example/view/frontend/templates/index.phtml (Go to our blog tutorial for full source code)
  • 11. Step 3: Activate the module in the configuration file 3.1 Activate module by opening app/etc/config.php file then add this line “'Tutorial_Example' => 1” into it: (Go to our blog tutorial for full source code)
  • 12. Step 3: Activate the module in the configuration file 3.2 Open the Command in Windows (or the Terminal in Linux and MAC OS). Go to Magento root folder and run this command line to install module: binmagento setup:upgrade (Go to our blog tutorial for full source code)
  • 13. Step 3: Activate the module in the configuration file 3.3 Clear the Magento cache then access with url http://localhost/magento2/example/index/index/
  • 14. Following MageWorld Magento 2 Tutorial Series…