SlideShare a Scribd company logo
1 of 24
Download to read offline
BEGINNERS’ GUIDE TO
MAGENTO PLUGINS,
EXTENSIONS, MODULES
TABLE OF CONTENT
1. Introduction
2. What is a Magento Plugin?
4. What are Magento Modules?
3. What is a Magento Extension?
5. Summary
6. Contact Us
01
02
02
3.1. Benefits of Magento Extensions 03
4.1. How to Create a Simple Module in Magento 2? 15
3.2. How to Develop a Magento Extension? 07
14
21
22
Page 01
1. INTRODUCTION
If you’re planning to learn about Magento 2 plugins & Magento 2
extensions in 2021, then congratulations because you’ve stumbled
onto the perfect resource to learn just that.
With cutting-edge technology, beautiful design, and robustfulness,
Magento 2 has always been the market leader among eCommerce
platforms.
And to further extend the awesomeness of this platform, there are
thousands of Magento plugins & extensions available for Magento
merchants.
In simple words, these Magento plugins & extensions help Magento
merchants to integrate a wide range of additional features &
functionalities to enhance the shopping experience & boost their
customer engagement rate, customer retention rate, and overall sales.
BUY BUY BUY
SKU
1
QTY
Quick Order
****
2
Page 02
2. WHAT IS A MAGENTO PLUGIN?
3. WHAT IS A MAGENTO EXTENSION?
Technically, a Magento plugin is something that allows you to insert code
dynamically without changing the original behavior of class.
In simple words, a Magento plugin basically allows you to extend the core
functionality without making any modifications to the core files.
Magento Extensions are basically add-on software modules that allow
Magento 2 stores to extend its functionalities.
Unlike Magento Plugins, Magento Extensions modify the core
functionality that is often needed because of either version
change or improvement.
They basically help to make each Magento 2 store unique, optimize, and
add additional features that are most beneficial for a specific store.
In simple words, Magento Extensions help to make a Magento 2 store
more attractive and grow conversions.
And the best part is, the number & type of Magento 2 Extensions that can
be developed is endless.
Page 03
3.1. BENEFITS OF MAGENTO 2 EXTENSIONS
Cost & Time Saving on
Magento 2 Store Development
One of the key reasons why the Magento platform is extremely popular
across the globe is not just because of its flexibility, but also because it
allows you to tweak appearance, feel, and alter any functionality according
to your business requirements.
Let’s take a look at the 5 key benefits that you can reap from Magento 2
Extensions.
If you use Magento 2 Extensions for
functionalities that you want instead of
custom development, there will be
drastic reduction in the overall Magento
2 Store development cost.
This is mainly because developers wouldn’t need to write hundreds of
lines of code for specific functionalities and can directly integrate &
configure the appropriate extension for the same functionality.
This, as a result, not only helps you save money but also the time it takes
for your Magento 2 Store to be ready for launch.
Page 04
Expands Your Business Reach
to Global Audience
Majority of eCommerce store owners
wish to expand their business to global
markets. But the main problem they all
face is the language barrier.
In simple words, when foreign customers are unable to understand
language used in your Magento 2 store, they often abandon your store
within seconds.
However, you can easily resolve this problem by simply integrating an
automatic language translator Magento 2 extension.
Here are the key functionalities provided by
language translator Magento 2 extension:
Enable mass translation
Set up multi-language stores
Translate product descriptions & meta details
Database search & translation
WYSIWYG editor
Page 05
Enhances Inventory
Management
Inventory management is one of the
most vital processes in any eCommerce
business. Even a slightest mistake in
inventory management can make a
notable dent in your profits.
Therefore, it is critical to handle it with utmost care & attention.
To keep everything balanced and enhance the inventory management
process in your Magento 2 store, you must consider integrating an
appropriate Magento 2 Extension for the same.
An ideal Inventory Management Magento 2
extension can help you with:
Product Inventory Management
Sales Order Management
Purchase Order Management
Multi-Store Support
Supplier Management
Page 06
Better Manage
On-Time Delivery & Tracking
Once your Magento 2 store is well-
established, you’ll start receiving a good
amount of orders per day. When this
happens, you need to be prepared &
ensure that you deliver all orders on time.
Now, if you use a manual approach to manage delivery, you’ll most
certainly end up landing yourself in big trouble.
But, if you leverage a delivery date Magento 2 Extension, not only will you be
able to better manage on-time delivery for all orders but you will also reap the
following benefits:
Let customers select delivery time & date
Display delivery time & date with charges
Keep track of delivery orders
Surpass your customers’ expectations
DELIVERY
Page 07
3.2. HOW TO DEVELOP A MAGENTO 2
EXTENSION?
Although, Magento 2 Extension Development is quite a complicated &
complex process.
But you can always begin to learn by developing a simple Hello World
extension.
Below is the complete, step-by-step process to develop a Hello World Ma-
gento 2 Extension.
Prerequisites:
Before you can begin to develop to a Magento 2 extension,
you need to make sure of the following:
1. Latest Magento 2 Version Installed
If you don’t know how to install Magento 2 on your system, you can refer
to our 5 Easy Steps to Install Magento 2 Using Composer Tutorial.
2. Magento Cache Disabled
Once you’ve installed Magento 2, you need to disable the Magento Cache.
The easiest way to disable Magento Cache is by logging in to your admin
panel and navigating to Admin > System > Cache Management and select
all cache types & disable them all.
Page 08
3. Magento Developer Mode Enabled
To put your Magento 2 Store into Developer Mode, open your terminal and
execute the following command:
php bin/magento deploy:mode:set developer
So, now that you have fulfilled all prerequisites for Magento 2 Extension
Development, it’s time we finally dive into the step-by-step process.
Step 1 - Extension Setup
First of all, you need to create the extension folder and necessary files to
register a Magento extension.
Specifically, you need to create the following folders:
app/code/MageDelight
app/code/MageDelight/HelloWorld
MageDelight is the Extension namespace and HelloWorld is the extension
name.
After creating the extension folders, you need to create a module.XML file
in the app/code/MageDelight/HelloWorld/etc directory and copy the
below code:
<?xml version=”1.0″?>
<config xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:noN-
a m e s p a c e S c h e m a L o c a t i o n = ” u r n : m a g e n t o : f r a m e w o r k : M o d -
ule/etc/module.xsd”>
<module name=”MageDelight_Helloworld” setup_version=”1.0.0″></module>
</config>
Page 09
Next, we need to register the above module.
For this, you need to create a registration.php file in the
app/code/MageDelight/HelloWorld directory and copy the following code:
<?php
MagentoFrameworkComponentComponentRegistrar::register(
MagentoFrameworkComponentComponentRegistrar::MODULE,
‘MageDelight_Helloworld’,
__DIR__
); ?>
Now, open the terminal in your system, navigate to the Magento 2 root
folder, and execute the following command:
php bin/magento setup:upgrade
After that, we need to make sure that the extension is installed
successfully.
To verify, simply open the admin panel, navigate to Admin > Stores >
Configuration > Advanced > Advanced and you’ll be able to see the name
of your new extension in the list.
Page 10
Step 2 - Create a Controller
The next step of creating a Magento 2 Extension is to create a controller.
And for this, we need to create a routes.XML file in the app/code/
MageDelight/HelloWorld/etc/frontend directory and copy the below code:
<?xml version=”1.0″?>
<config xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:noN-
amespaceSchemaLocation=”urn:magento:framework:App/etc/routes.xsd”>
<router id=”standard”>
<route id=”helloworld” frontName=”helloworld”>
<module name=”MageDelight_Helloworld” />
</route>
</router>
</config>
As you can see in the above code, we have defined the frontend router &
route with “helloworld” id.
In Magento 2, the URLs are constructed as shown below:
<frontName>/<controler_folder_name>/<controller_class_name>
So, in our case, the final URL of our new Magento 2 Extension will look like
this:
helloworld/index/index
Page 11
Next, you need to create an index.php file in the app/code/
MageDelight/HelloWorld/Controller/Index directory and copy
the following code:
<?php
namespace MageDelightHelloworldControllerIndex;
use MagentoFrameworkAppActionContext;
class Index extends MagentoFrameworkAppActionAction
{
protected $_resultPageFactory;
public function __construct(Context $context, MagentoFrame-
workViewResultPageFactory $resultPageFactory)
{
$this->_resultPageFactory = $resultPageFactory;
parent::__construct($context);
}
public function execute()
{
$resultPage = $this->_resultPageFactory->create();
return $resultPage;
}
}
Page 12
Now, the next step is to create a simpleWhat are Magento Modules?
block class along with getHelloWorldTxt() method which will return
“Hello World” text upon execution.
For this, first you need to create a HelloWorld.php file in the
app/code/MageDelight/HelloWorld/Block directory and copy the
following code:
<?php
namespace MageDelightHelloworldBlock;
class Helloworld extends MagentoFrameworkViewElementTem-
plate
{
public function getHelloWorldTxt()
{
return ‘Hello MageDelight, This is your first hello world magento
Extension!’;
}
}
The layout & template files in Magento 2 are generally placed inside the
view folder of your extension.
And inside the view folder, you can create 3 subfolders: adminhtml, base,
& frontend.
The adminhtml folder is for admin, frontend folder is for frontend, and
base folder is for admin & frontend files both.
Step 3 - Create a Block
Step 4 - Create Layout & Template Files
Page 13
Now, let’s start with creating the layout & template files.
First of all, create a helloworld_index_index.XML file in the
app/code/MageDelight/HelloWorld/view/frontend/layout directory and
copy the following code:
<page xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:noN-
a m e s p a c e S c h e m a L o c a t i o n = ” . . / . . / . . / . . / . . / . . / . . / l i b / i n t e r -
nal/Magento/Framework/
View/Layout/etc/page_configuration.xsd” layout=”1column”>
<body>
<referenceContainer name=”content”>
<block class=”MageDelightHelloworldBlockHelloworld” name=”helloworld”
template=”helloworld.phtml” />
</referenceContainer>
</body>
</page>
You see, every page in the Magento 2 store has a layout handle. And for
our controller action, the layout handle is helloworld_index_index.
In addition, we have also added a block to the content container in our
layout file & set the template to helloworld.phtml, which will create just
below.
Next, create a helloworld.phtml file in the app/code/MageDelight/
view/frontend/templates directory and copy the following code:
<h1><?php echo $this->getHelloWorldTxt(); ?></h1>
The $This variable in the above code is referencing our block class &
calling the getHelloWorldTxt() method that will return the “Hello World”
string.
And that’s about it!
You have now finally completed all steps to create a simple Magento 2
Extension.
Page 14
4. WHAT ARE MAGENTO MODULES?
A Magento module is basically a folder that contains blocks, models,
controllers, helper, etc. files that are required to develop a specific
business feature.
It is an independent component or a set of components that provide a
Magento 2 store with business logic & features.
Put another way, all the functionalities in Magento 2 stores are
implemented and delivered in components, which are known as modules.
In a nutshell, a module & an extension in Magento 2 is basically the same
thing.
That being said, let’s look at the step by step process to create a simple
module in Magento 2.
Page 15
4.1 HOW TO CREATE A SIMPLE MODULE
IN MAGENTO 2?
Here’s an easy-to-follow tutorial on How to create a simple
module in Magento 2.
Prerequisites for Creating a Simple Module in Magento 2
Directory for the module
Configuration for the module
Registration for the module
Front-end router file
Controller file
Block file
Front-end layout file
Front-end template file
Install setup and Enable module
Page 16
So, these are the steps we need to take in order to create a simple module
in Magento 2.
Let’s get started!
Directory for the module
In order to create a simple Magento 2 module, firstly we need to set up the
structure of the module.
And for that, we need to create the following Folders in app/code.
MageDelight: namespace name
Helloworld: module name
Controller: Controls the flow of the module action
Block: Contains the PHP file of the module
etc: Configuration related file of the module.
etc/frontend: front-end router file will be available here.
view/frontend/layout: frontend layout (XML) file will be available here.
view/frontend/template: frontend template (.phtml) file.
Page 17
Configuration for the module
The next step is to set the configuration for our module.
In order to that, we need to create module.xml file in the following directory
- app/code/MageDelight/Helloworld/etc
Now, paste the following code into the module.xml file.
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noN-
a m e s p a c e S c h e m a L o c a t i o n = " . . / . . / . . / . . / . . / l i b / i n t e r -
nal/Magento/Framework/Module/etc/module.xsd">
<module name="MageDelight_Helloworld" schema_version="0.0.1"
setup_version="0.0.1">
</module>
</config>
Registration of Module
Now, we need to perform the registration of our module.
To do this, we need to create a registration.php file app/code/MageDe-
light/Helloworld and paste the following code:
<?php
MagentoFrameworkComponentComponentRegistrar::register(
MagentoFrameworkComponentComponentRegistrar::MODULE,
'MageDelight_Helloworld',
__DIR__
);
Page 18
Front-end router file
The front-end router file is basically required to set a router name for the
front page to be able to access it from the front side.
So, let’s create the routes.xml file in app/code/MageDelight/
Helloworld/etc/frontend and add the following code:
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noN-
amespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
<router id="standard">
<route id="helloworld" frontName="helloworld">
<module name="MageDelight_Helloworld"/>
</route>
</router>
</config>
Controller File
Once you’ve created the front-end router file, it’s time to move forward and
create a Controller file, which will be used to execute the action of our
module.
So, let’s go ahead and create index.php file in app/code/MageDelight/
Helloworld/Controller/Index and paste the following code for executing
the module’s action.
Page 19
<?php
namespace MageDelightHelloworldControllerIndex;
class Index extends MagentoFrameworkAppActionAction
{
/**
* @var MagentoFrameworkViewResultPageFactory
*/
protected $resultPageFactory;
/**
* @param MagentoFrameworkAppActionContext $context
* @param MagentoFrameworkViewResultPageFactory resultPageFac-
tory
*/
public function __construct(
MagentoFrameworkAppActionContext $context,
MagentoFrameworkViewResultPageFactory $resultPageFacto-
ry
)
{
$this->resultPageFactory = $resultPageFactory;
parent::__construct($context);
}
/**
* Default customer account page
*
* @return void
*/
public function execute()
{
$resultPage = $this->resultPageFactory->create();
$resultPage->getConfig()->getTitle()->prepend(__('Welcome to
MageDelight Helloworld module'));
return $resultPage;
}
}
?>
Once you’ve pasted the code, it’s time we check the output via the
following URL: http://domain.com/helloworld/index/index
Page 20
Block file
The block file will basically contain PHP view classes.
So, let’s create a file name called helloworld.php inside app/code/
MageDelight/Helloworld/Block directory with the following code:
<?php
namespace MageDelightHelloworldBlock;
class Helloworld extends MagentoFrameworkViewElementTemplate
{
public function __construct(
MagentoFrameworkViewElementTemplateContext $context,
array $data = []
)
{
parent::__construct($context, $data);
}
public function getHelloworldData()
{
return 'MageDelight Helloworld block file call successfully';
}
}
?>
Front-end Layout File
Now, we need to call block function as well as execute some design codes.
So, let’s create a helloworld.html file inside the app/code/
MageDelight/Helloworld/view/frontend/templates directory and add the
below code.
<h3>
<?php echo $block->getHelloworldData(); ?>
</h3>
Page 21
SUMMARY
Magento plugins, extensions, & modules have become a critical part of
all Magento 2 stores nowadays. Therefore, it is of utmost importance to
leverage its power when building a Magento 2 store to both survive &
thrive in today’s competitive market.
That being said, whether you’re looking for the best Magento 2
Extensions in the market or need to build custom Magento 2 Extensions
for specifically your online store, share your requirements with us & we
promise to deliver 100% accurate & high quality according to your
business requirements.
Send an email to sales@magedelight.com or fill out the contact us form
on our website and our expert consultants will get in touch with you
within 24 hours.
CONTACT US
Harness Our High-end Magento Deliverables to Stay
Abreast the Latest Trends Following eCommerce.
Our team of experts will be
happy to assist you.
Details Available on
www.magedelight.com
For Queries, Write Us At..
sales@magedelight.com
Call Us on
079 2644 7810

More Related Content

What's hot

How to Install Magento 2 [Latest Version]
How to Install Magento 2 [Latest Version]How to Install Magento 2 [Latest Version]
How to Install Magento 2 [Latest Version]M-Connect Media
 
Product image zoom setup in Magento
Product image zoom setup in MagentoProduct image zoom setup in Magento
Product image zoom setup in MagentoKetan Raval
 
How to Install Magento Theme
How to Install Magento ThemeHow to Install Magento Theme
How to Install Magento ThemeM-Connect Media
 
Magento 2 Import Coupon Codes
Magento 2 Import Coupon CodesMagento 2 Import Coupon Codes
Magento 2 Import Coupon CodesMageAnts
 
How to Install Magento Extensions - Tutorial
How to Install Magento Extensions - TutorialHow to Install Magento Extensions - Tutorial
How to Install Magento Extensions - TutorialM-Connect Media
 
Magento 2 Responsive banner slider
Magento 2 Responsive banner sliderMagento 2 Responsive banner slider
Magento 2 Responsive banner sliderMageAnts
 
Size chart for magento 2
Size chart for magento 2Size chart for magento 2
Size chart for magento 2MageAnts
 
Magento 2 Advance Shop By Brand Extension
Magento 2 Advance Shop By Brand ExtensionMagento 2 Advance Shop By Brand Extension
Magento 2 Advance Shop By Brand ExtensionAppJetty
 
User guide
User guideUser guide
User guidenhockiki
 
Advanced Permissions: Magento Extension by Amasty. User Guide.
Advanced Permissions: Magento Extension by Amasty. User Guide.Advanced Permissions: Magento Extension by Amasty. User Guide.
Advanced Permissions: Magento Extension by Amasty. User Guide.Amasty
 
Ocodewire world_store_locator_extension_demo
Ocodewire world_store_locator_extension_demoOcodewire world_store_locator_extension_demo
Ocodewire world_store_locator_extension_demoMagento oCodewire
 
Magento 2 admin payment method pro
Magento 2  admin payment method proMagento 2  admin payment method pro
Magento 2 admin payment method proLandofcoder
 
MageMob Cart Android & iOS Application
MageMob Cart Android & iOS ApplicationMageMob Cart Android & iOS Application
MageMob Cart Android & iOS ApplicationAppJetty
 
Efficient Order Export: Magento Extension by Amasty. User Guide.
Efficient Order Export: Magento Extension by Amasty. User Guide.Efficient Order Export: Magento Extension by Amasty. User Guide.
Efficient Order Export: Magento Extension by Amasty. User Guide.Amasty
 
UkNuke Facebook Connect Authentication For DotNetNuke 5
UkNuke Facebook Connect Authentication For DotNetNuke 5UkNuke Facebook Connect Authentication For DotNetNuke 5
UkNuke Facebook Connect Authentication For DotNetNuke 5Stuart Lodge
 
Windward Magento Integration - Manuals
Windward Magento Integration - ManualsWindward Magento Integration - Manuals
Windward Magento Integration - ManualsOmnichannel Commerce
 
Magento 2 facebook shop
Magento 2 facebook shopMagento 2 facebook shop
Magento 2 facebook shopTheMagicians
 
Uk Nuke Facebook Connect Authentication For Dot Net Nuke
Uk Nuke Facebook Connect Authentication For Dot Net NukeUk Nuke Facebook Connect Authentication For Dot Net Nuke
Uk Nuke Facebook Connect Authentication For Dot Net NukeStuart Lodge
 

What's hot (19)

How to Install Magento 2 [Latest Version]
How to Install Magento 2 [Latest Version]How to Install Magento 2 [Latest Version]
How to Install Magento 2 [Latest Version]
 
Product image zoom setup in Magento
Product image zoom setup in MagentoProduct image zoom setup in Magento
Product image zoom setup in Magento
 
How to Install Magento Theme
How to Install Magento ThemeHow to Install Magento Theme
How to Install Magento Theme
 
Magento 2 Import Coupon Codes
Magento 2 Import Coupon CodesMagento 2 Import Coupon Codes
Magento 2 Import Coupon Codes
 
How to Install Magento Extensions - Tutorial
How to Install Magento Extensions - TutorialHow to Install Magento Extensions - Tutorial
How to Install Magento Extensions - Tutorial
 
Magento 2 Responsive banner slider
Magento 2 Responsive banner sliderMagento 2 Responsive banner slider
Magento 2 Responsive banner slider
 
Size chart for magento 2
Size chart for magento 2Size chart for magento 2
Size chart for magento 2
 
Magento 2 Advance Shop By Brand Extension
Magento 2 Advance Shop By Brand ExtensionMagento 2 Advance Shop By Brand Extension
Magento 2 Advance Shop By Brand Extension
 
User guide
User guideUser guide
User guide
 
Advanced Permissions: Magento Extension by Amasty. User Guide.
Advanced Permissions: Magento Extension by Amasty. User Guide.Advanced Permissions: Magento Extension by Amasty. User Guide.
Advanced Permissions: Magento Extension by Amasty. User Guide.
 
Ocodewire world_store_locator_extension_demo
Ocodewire world_store_locator_extension_demoOcodewire world_store_locator_extension_demo
Ocodewire world_store_locator_extension_demo
 
Magento 2 admin payment method pro
Magento 2  admin payment method proMagento 2  admin payment method pro
Magento 2 admin payment method pro
 
MageMob Cart Android & iOS Application
MageMob Cart Android & iOS ApplicationMageMob Cart Android & iOS Application
MageMob Cart Android & iOS Application
 
Efficient Order Export: Magento Extension by Amasty. User Guide.
Efficient Order Export: Magento Extension by Amasty. User Guide.Efficient Order Export: Magento Extension by Amasty. User Guide.
Efficient Order Export: Magento Extension by Amasty. User Guide.
 
UkNuke Facebook Connect Authentication For DotNetNuke 5
UkNuke Facebook Connect Authentication For DotNetNuke 5UkNuke Facebook Connect Authentication For DotNetNuke 5
UkNuke Facebook Connect Authentication For DotNetNuke 5
 
Advanced faq magento
Advanced faq magentoAdvanced faq magento
Advanced faq magento
 
Windward Magento Integration - Manuals
Windward Magento Integration - ManualsWindward Magento Integration - Manuals
Windward Magento Integration - Manuals
 
Magento 2 facebook shop
Magento 2 facebook shopMagento 2 facebook shop
Magento 2 facebook shop
 
Uk Nuke Facebook Connect Authentication For Dot Net Nuke
Uk Nuke Facebook Connect Authentication For Dot Net NukeUk Nuke Facebook Connect Authentication For Dot Net Nuke
Uk Nuke Facebook Connect Authentication For Dot Net Nuke
 

Similar to BEGINNERS’ GUIDE TO MAGENTO PLUGINS, EXTENSIONS, MODULES

What are benefits of magento for ecommerce store
What are benefits of magento for ecommerce storeWhat are benefits of magento for ecommerce store
What are benefits of magento for ecommerce storeNCode Technologies, Inc.
 
Magento 2 community edition and enterprise edition what suits you best
Magento 2 community edition and enterprise edition  what suits you bestMagento 2 community edition and enterprise edition  what suits you best
Magento 2 community edition and enterprise edition what suits you bestIDS Logic Pvt. Ltd.
 
How upgrading to Magento 2.0 will fuel your growth?
How upgrading to Magento 2.0 will fuel your growth? How upgrading to Magento 2.0 will fuel your growth?
How upgrading to Magento 2.0 will fuel your growth? Designomate
 
Know Why Magento 2 Migration Service Is Significant For Ecommerce Business.pptx
Know Why Magento 2 Migration Service Is Significant For Ecommerce Business.pptxKnow Why Magento 2 Migration Service Is Significant For Ecommerce Business.pptx
Know Why Magento 2 Migration Service Is Significant For Ecommerce Business.pptxAgento Support
 
Magento vs big commerce a detailed comparison guide - ziffity
Magento vs big commerce  a detailed comparison guide - ziffityMagento vs big commerce  a detailed comparison guide - ziffity
Magento vs big commerce a detailed comparison guide - ziffityZiffity Solutions LLC
 
Must have magento 2 extensions for 2022
Must have magento 2 extensions for 2022Must have magento 2 extensions for 2022
Must have magento 2 extensions for 2022SunCart Store
 
Magento 2 Migration Issues: Top 7 Most Common Challenges to Consider
Magento 2 Migration Issues: Top 7 Most Common Challenges to ConsiderMagento 2 Migration Issues: Top 7 Most Common Challenges to Consider
Magento 2 Migration Issues: Top 7 Most Common Challenges to ConsiderEVRIG Solutions
 
Split order on checkout pro extensions of magento
Split order on checkout pro extensions of magentoSplit order on checkout pro extensions of magento
Split order on checkout pro extensions of magentoSunCart Store
 
Why you choose Magento as your ecommerce platform?
Why you choose Magento as your ecommerce platform? Why you choose Magento as your ecommerce platform?
Why you choose Magento as your ecommerce platform? Inception System
 
Drive More Traffic on Your Magento 2 eCommerce Store with Best Magento 2 SEO ...
Drive More Traffic on Your Magento 2 eCommerce Store with Best Magento 2 SEO ...Drive More Traffic on Your Magento 2 eCommerce Store with Best Magento 2 SEO ...
Drive More Traffic on Your Magento 2 eCommerce Store with Best Magento 2 SEO ...magePoint
 
Magento 2 Google Rich Snippets
Magento 2 Google Rich SnippetsMagento 2 Google Rich Snippets
Magento 2 Google Rich SnippetsMageAnts
 
Expense to Build an Online Store with Magento.pptx
Expense to Build an Online Store with Magento.pptxExpense to Build an Online Store with Magento.pptx
Expense to Build an Online Store with Magento.pptxAgento Support
 
Magento 2 Language Translator Extension
Magento 2 Language Translator ExtensionMagento 2 Language Translator Extension
Magento 2 Language Translator ExtensionAppJetty
 
Know Why Magento Development Services Are The Best For Ecommerce Business.pptx
Know Why Magento Development Services Are The Best For Ecommerce Business.pptxKnow Why Magento Development Services Are The Best For Ecommerce Business.pptx
Know Why Magento Development Services Are The Best For Ecommerce Business.pptxAgento Support
 
New Features in Magento Enterprise Edition 1.14 (EE) Magento Community Editio...
New Features in Magento Enterprise Edition 1.14 (EE) Magento Community Editio...New Features in Magento Enterprise Edition 1.14 (EE) Magento Community Editio...
New Features in Magento Enterprise Edition 1.14 (EE) Magento Community Editio...Mike Taylor
 
Magento 2 Inventory Management Extension
Magento 2 Inventory Management ExtensionMagento 2 Inventory Management Extension
Magento 2 Inventory Management ExtensionAppJetty
 

Similar to BEGINNERS’ GUIDE TO MAGENTO PLUGINS, EXTENSIONS, MODULES (20)

How to install Magento 2 extensions.pptx
How to install Magento 2 extensions.pptxHow to install Magento 2 extensions.pptx
How to install Magento 2 extensions.pptx
 
What are benefits of magento for ecommerce store
What are benefits of magento for ecommerce storeWhat are benefits of magento for ecommerce store
What are benefits of magento for ecommerce store
 
Magento 2 community edition and enterprise edition what suits you best
Magento 2 community edition and enterprise edition  what suits you bestMagento 2 community edition and enterprise edition  what suits you best
Magento 2 community edition and enterprise edition what suits you best
 
How upgrading to Magento 2.0 will fuel your growth?
How upgrading to Magento 2.0 will fuel your growth? How upgrading to Magento 2.0 will fuel your growth?
How upgrading to Magento 2.0 will fuel your growth?
 
Know Why Magento 2 Migration Service Is Significant For Ecommerce Business.pptx
Know Why Magento 2 Migration Service Is Significant For Ecommerce Business.pptxKnow Why Magento 2 Migration Service Is Significant For Ecommerce Business.pptx
Know Why Magento 2 Migration Service Is Significant For Ecommerce Business.pptx
 
Magento vs big commerce a detailed comparison guide - ziffity
Magento vs big commerce  a detailed comparison guide - ziffityMagento vs big commerce  a detailed comparison guide - ziffity
Magento vs big commerce a detailed comparison guide - ziffity
 
Must have magento 2 extensions for 2022
Must have magento 2 extensions for 2022Must have magento 2 extensions for 2022
Must have magento 2 extensions for 2022
 
Magento 2 Migration Issues: Top 7 Most Common Challenges to Consider
Magento 2 Migration Issues: Top 7 Most Common Challenges to ConsiderMagento 2 Migration Issues: Top 7 Most Common Challenges to Consider
Magento 2 Migration Issues: Top 7 Most Common Challenges to Consider
 
Split order on checkout pro extensions of magento
Split order on checkout pro extensions of magentoSplit order on checkout pro extensions of magento
Split order on checkout pro extensions of magento
 
Why you choose Magento as your ecommerce platform?
Why you choose Magento as your ecommerce platform? Why you choose Magento as your ecommerce platform?
Why you choose Magento as your ecommerce platform?
 
Magento 2 Migration - features & demography 2018
Magento 2 Migration -  features & demography 2018Magento 2 Migration -  features & demography 2018
Magento 2 Migration - features & demography 2018
 
Drive More Traffic on Your Magento 2 eCommerce Store with Best Magento 2 SEO ...
Drive More Traffic on Your Magento 2 eCommerce Store with Best Magento 2 SEO ...Drive More Traffic on Your Magento 2 eCommerce Store with Best Magento 2 SEO ...
Drive More Traffic on Your Magento 2 eCommerce Store with Best Magento 2 SEO ...
 
Magento 2 Google Rich Snippets
Magento 2 Google Rich SnippetsMagento 2 Google Rich Snippets
Magento 2 Google Rich Snippets
 
Expense to Build an Online Store with Magento.pptx
Expense to Build an Online Store with Magento.pptxExpense to Build an Online Store with Magento.pptx
Expense to Build an Online Store with Magento.pptx
 
Magento 2 Language Translator Extension
Magento 2 Language Translator ExtensionMagento 2 Language Translator Extension
Magento 2 Language Translator Extension
 
Magento 2 Community Vs Enterprise Edition Comparison
Magento 2 Community Vs Enterprise Edition ComparisonMagento 2 Community Vs Enterprise Edition Comparison
Magento 2 Community Vs Enterprise Edition Comparison
 
12 Amazing Features of Magento 2
12 Amazing Features of Magento 212 Amazing Features of Magento 2
12 Amazing Features of Magento 2
 
Know Why Magento Development Services Are The Best For Ecommerce Business.pptx
Know Why Magento Development Services Are The Best For Ecommerce Business.pptxKnow Why Magento Development Services Are The Best For Ecommerce Business.pptx
Know Why Magento Development Services Are The Best For Ecommerce Business.pptx
 
New Features in Magento Enterprise Edition 1.14 (EE) Magento Community Editio...
New Features in Magento Enterprise Edition 1.14 (EE) Magento Community Editio...New Features in Magento Enterprise Edition 1.14 (EE) Magento Community Editio...
New Features in Magento Enterprise Edition 1.14 (EE) Magento Community Editio...
 
Magento 2 Inventory Management Extension
Magento 2 Inventory Management ExtensionMagento 2 Inventory Management Extension
Magento 2 Inventory Management Extension
 

Recently uploaded

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
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
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
 
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
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
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
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
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
 
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
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
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
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 

Recently uploaded (20)

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...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
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
 
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
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
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
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.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...
 
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...
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
 
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...
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
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...
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 

BEGINNERS’ GUIDE TO MAGENTO PLUGINS, EXTENSIONS, MODULES

  • 1. BEGINNERS’ GUIDE TO MAGENTO PLUGINS, EXTENSIONS, MODULES
  • 2. TABLE OF CONTENT 1. Introduction 2. What is a Magento Plugin? 4. What are Magento Modules? 3. What is a Magento Extension? 5. Summary 6. Contact Us 01 02 02 3.1. Benefits of Magento Extensions 03 4.1. How to Create a Simple Module in Magento 2? 15 3.2. How to Develop a Magento Extension? 07 14 21 22
  • 3. Page 01 1. INTRODUCTION If you’re planning to learn about Magento 2 plugins & Magento 2 extensions in 2021, then congratulations because you’ve stumbled onto the perfect resource to learn just that. With cutting-edge technology, beautiful design, and robustfulness, Magento 2 has always been the market leader among eCommerce platforms. And to further extend the awesomeness of this platform, there are thousands of Magento plugins & extensions available for Magento merchants. In simple words, these Magento plugins & extensions help Magento merchants to integrate a wide range of additional features & functionalities to enhance the shopping experience & boost their customer engagement rate, customer retention rate, and overall sales. BUY BUY BUY SKU 1 QTY Quick Order **** 2
  • 4. Page 02 2. WHAT IS A MAGENTO PLUGIN? 3. WHAT IS A MAGENTO EXTENSION? Technically, a Magento plugin is something that allows you to insert code dynamically without changing the original behavior of class. In simple words, a Magento plugin basically allows you to extend the core functionality without making any modifications to the core files. Magento Extensions are basically add-on software modules that allow Magento 2 stores to extend its functionalities. Unlike Magento Plugins, Magento Extensions modify the core functionality that is often needed because of either version change or improvement. They basically help to make each Magento 2 store unique, optimize, and add additional features that are most beneficial for a specific store. In simple words, Magento Extensions help to make a Magento 2 store more attractive and grow conversions. And the best part is, the number & type of Magento 2 Extensions that can be developed is endless.
  • 5. Page 03 3.1. BENEFITS OF MAGENTO 2 EXTENSIONS Cost & Time Saving on Magento 2 Store Development One of the key reasons why the Magento platform is extremely popular across the globe is not just because of its flexibility, but also because it allows you to tweak appearance, feel, and alter any functionality according to your business requirements. Let’s take a look at the 5 key benefits that you can reap from Magento 2 Extensions. If you use Magento 2 Extensions for functionalities that you want instead of custom development, there will be drastic reduction in the overall Magento 2 Store development cost. This is mainly because developers wouldn’t need to write hundreds of lines of code for specific functionalities and can directly integrate & configure the appropriate extension for the same functionality. This, as a result, not only helps you save money but also the time it takes for your Magento 2 Store to be ready for launch.
  • 6. Page 04 Expands Your Business Reach to Global Audience Majority of eCommerce store owners wish to expand their business to global markets. But the main problem they all face is the language barrier. In simple words, when foreign customers are unable to understand language used in your Magento 2 store, they often abandon your store within seconds. However, you can easily resolve this problem by simply integrating an automatic language translator Magento 2 extension. Here are the key functionalities provided by language translator Magento 2 extension: Enable mass translation Set up multi-language stores Translate product descriptions & meta details Database search & translation WYSIWYG editor
  • 7. Page 05 Enhances Inventory Management Inventory management is one of the most vital processes in any eCommerce business. Even a slightest mistake in inventory management can make a notable dent in your profits. Therefore, it is critical to handle it with utmost care & attention. To keep everything balanced and enhance the inventory management process in your Magento 2 store, you must consider integrating an appropriate Magento 2 Extension for the same. An ideal Inventory Management Magento 2 extension can help you with: Product Inventory Management Sales Order Management Purchase Order Management Multi-Store Support Supplier Management
  • 8. Page 06 Better Manage On-Time Delivery & Tracking Once your Magento 2 store is well- established, you’ll start receiving a good amount of orders per day. When this happens, you need to be prepared & ensure that you deliver all orders on time. Now, if you use a manual approach to manage delivery, you’ll most certainly end up landing yourself in big trouble. But, if you leverage a delivery date Magento 2 Extension, not only will you be able to better manage on-time delivery for all orders but you will also reap the following benefits: Let customers select delivery time & date Display delivery time & date with charges Keep track of delivery orders Surpass your customers’ expectations DELIVERY
  • 9. Page 07 3.2. HOW TO DEVELOP A MAGENTO 2 EXTENSION? Although, Magento 2 Extension Development is quite a complicated & complex process. But you can always begin to learn by developing a simple Hello World extension. Below is the complete, step-by-step process to develop a Hello World Ma- gento 2 Extension. Prerequisites: Before you can begin to develop to a Magento 2 extension, you need to make sure of the following: 1. Latest Magento 2 Version Installed If you don’t know how to install Magento 2 on your system, you can refer to our 5 Easy Steps to Install Magento 2 Using Composer Tutorial. 2. Magento Cache Disabled Once you’ve installed Magento 2, you need to disable the Magento Cache. The easiest way to disable Magento Cache is by logging in to your admin panel and navigating to Admin > System > Cache Management and select all cache types & disable them all.
  • 10. Page 08 3. Magento Developer Mode Enabled To put your Magento 2 Store into Developer Mode, open your terminal and execute the following command: php bin/magento deploy:mode:set developer So, now that you have fulfilled all prerequisites for Magento 2 Extension Development, it’s time we finally dive into the step-by-step process. Step 1 - Extension Setup First of all, you need to create the extension folder and necessary files to register a Magento extension. Specifically, you need to create the following folders: app/code/MageDelight app/code/MageDelight/HelloWorld MageDelight is the Extension namespace and HelloWorld is the extension name. After creating the extension folders, you need to create a module.XML file in the app/code/MageDelight/HelloWorld/etc directory and copy the below code: <?xml version=”1.0″?> <config xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:noN- a m e s p a c e S c h e m a L o c a t i o n = ” u r n : m a g e n t o : f r a m e w o r k : M o d - ule/etc/module.xsd”> <module name=”MageDelight_Helloworld” setup_version=”1.0.0″></module> </config>
  • 11. Page 09 Next, we need to register the above module. For this, you need to create a registration.php file in the app/code/MageDelight/HelloWorld directory and copy the following code: <?php MagentoFrameworkComponentComponentRegistrar::register( MagentoFrameworkComponentComponentRegistrar::MODULE, ‘MageDelight_Helloworld’, __DIR__ ); ?> Now, open the terminal in your system, navigate to the Magento 2 root folder, and execute the following command: php bin/magento setup:upgrade After that, we need to make sure that the extension is installed successfully. To verify, simply open the admin panel, navigate to Admin > Stores > Configuration > Advanced > Advanced and you’ll be able to see the name of your new extension in the list.
  • 12. Page 10 Step 2 - Create a Controller The next step of creating a Magento 2 Extension is to create a controller. And for this, we need to create a routes.XML file in the app/code/ MageDelight/HelloWorld/etc/frontend directory and copy the below code: <?xml version=”1.0″?> <config xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:noN- amespaceSchemaLocation=”urn:magento:framework:App/etc/routes.xsd”> <router id=”standard”> <route id=”helloworld” frontName=”helloworld”> <module name=”MageDelight_Helloworld” /> </route> </router> </config> As you can see in the above code, we have defined the frontend router & route with “helloworld” id. In Magento 2, the URLs are constructed as shown below: <frontName>/<controler_folder_name>/<controller_class_name> So, in our case, the final URL of our new Magento 2 Extension will look like this: helloworld/index/index
  • 13. Page 11 Next, you need to create an index.php file in the app/code/ MageDelight/HelloWorld/Controller/Index directory and copy the following code: <?php namespace MageDelightHelloworldControllerIndex; use MagentoFrameworkAppActionContext; class Index extends MagentoFrameworkAppActionAction { protected $_resultPageFactory; public function __construct(Context $context, MagentoFrame- workViewResultPageFactory $resultPageFactory) { $this->_resultPageFactory = $resultPageFactory; parent::__construct($context); } public function execute() { $resultPage = $this->_resultPageFactory->create(); return $resultPage; } }
  • 14. Page 12 Now, the next step is to create a simpleWhat are Magento Modules? block class along with getHelloWorldTxt() method which will return “Hello World” text upon execution. For this, first you need to create a HelloWorld.php file in the app/code/MageDelight/HelloWorld/Block directory and copy the following code: <?php namespace MageDelightHelloworldBlock; class Helloworld extends MagentoFrameworkViewElementTem- plate { public function getHelloWorldTxt() { return ‘Hello MageDelight, This is your first hello world magento Extension!’; } } The layout & template files in Magento 2 are generally placed inside the view folder of your extension. And inside the view folder, you can create 3 subfolders: adminhtml, base, & frontend. The adminhtml folder is for admin, frontend folder is for frontend, and base folder is for admin & frontend files both. Step 3 - Create a Block Step 4 - Create Layout & Template Files
  • 15. Page 13 Now, let’s start with creating the layout & template files. First of all, create a helloworld_index_index.XML file in the app/code/MageDelight/HelloWorld/view/frontend/layout directory and copy the following code: <page xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:noN- a m e s p a c e S c h e m a L o c a t i o n = ” . . / . . / . . / . . / . . / . . / . . / l i b / i n t e r - nal/Magento/Framework/ View/Layout/etc/page_configuration.xsd” layout=”1column”> <body> <referenceContainer name=”content”> <block class=”MageDelightHelloworldBlockHelloworld” name=”helloworld” template=”helloworld.phtml” /> </referenceContainer> </body> </page> You see, every page in the Magento 2 store has a layout handle. And for our controller action, the layout handle is helloworld_index_index. In addition, we have also added a block to the content container in our layout file & set the template to helloworld.phtml, which will create just below. Next, create a helloworld.phtml file in the app/code/MageDelight/ view/frontend/templates directory and copy the following code: <h1><?php echo $this->getHelloWorldTxt(); ?></h1> The $This variable in the above code is referencing our block class & calling the getHelloWorldTxt() method that will return the “Hello World” string. And that’s about it! You have now finally completed all steps to create a simple Magento 2 Extension.
  • 16. Page 14 4. WHAT ARE MAGENTO MODULES? A Magento module is basically a folder that contains blocks, models, controllers, helper, etc. files that are required to develop a specific business feature. It is an independent component or a set of components that provide a Magento 2 store with business logic & features. Put another way, all the functionalities in Magento 2 stores are implemented and delivered in components, which are known as modules. In a nutshell, a module & an extension in Magento 2 is basically the same thing. That being said, let’s look at the step by step process to create a simple module in Magento 2.
  • 17. Page 15 4.1 HOW TO CREATE A SIMPLE MODULE IN MAGENTO 2? Here’s an easy-to-follow tutorial on How to create a simple module in Magento 2. Prerequisites for Creating a Simple Module in Magento 2 Directory for the module Configuration for the module Registration for the module Front-end router file Controller file Block file Front-end layout file Front-end template file Install setup and Enable module
  • 18. Page 16 So, these are the steps we need to take in order to create a simple module in Magento 2. Let’s get started! Directory for the module In order to create a simple Magento 2 module, firstly we need to set up the structure of the module. And for that, we need to create the following Folders in app/code. MageDelight: namespace name Helloworld: module name Controller: Controls the flow of the module action Block: Contains the PHP file of the module etc: Configuration related file of the module. etc/frontend: front-end router file will be available here. view/frontend/layout: frontend layout (XML) file will be available here. view/frontend/template: frontend template (.phtml) file.
  • 19. Page 17 Configuration for the module The next step is to set the configuration for our module. In order to that, we need to create module.xml file in the following directory - app/code/MageDelight/Helloworld/etc Now, paste the following code into the module.xml file. <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noN- a m e s p a c e S c h e m a L o c a t i o n = " . . / . . / . . / . . / . . / l i b / i n t e r - nal/Magento/Framework/Module/etc/module.xsd"> <module name="MageDelight_Helloworld" schema_version="0.0.1" setup_version="0.0.1"> </module> </config> Registration of Module Now, we need to perform the registration of our module. To do this, we need to create a registration.php file app/code/MageDe- light/Helloworld and paste the following code: <?php MagentoFrameworkComponentComponentRegistrar::register( MagentoFrameworkComponentComponentRegistrar::MODULE, 'MageDelight_Helloworld', __DIR__ );
  • 20. Page 18 Front-end router file The front-end router file is basically required to set a router name for the front page to be able to access it from the front side. So, let’s create the routes.xml file in app/code/MageDelight/ Helloworld/etc/frontend and add the following code: <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noN- amespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd"> <router id="standard"> <route id="helloworld" frontName="helloworld"> <module name="MageDelight_Helloworld"/> </route> </router> </config> Controller File Once you’ve created the front-end router file, it’s time to move forward and create a Controller file, which will be used to execute the action of our module. So, let’s go ahead and create index.php file in app/code/MageDelight/ Helloworld/Controller/Index and paste the following code for executing the module’s action.
  • 21. Page 19 <?php namespace MageDelightHelloworldControllerIndex; class Index extends MagentoFrameworkAppActionAction { /** * @var MagentoFrameworkViewResultPageFactory */ protected $resultPageFactory; /** * @param MagentoFrameworkAppActionContext $context * @param MagentoFrameworkViewResultPageFactory resultPageFac- tory */ public function __construct( MagentoFrameworkAppActionContext $context, MagentoFrameworkViewResultPageFactory $resultPageFacto- ry ) { $this->resultPageFactory = $resultPageFactory; parent::__construct($context); } /** * Default customer account page * * @return void */ public function execute() { $resultPage = $this->resultPageFactory->create(); $resultPage->getConfig()->getTitle()->prepend(__('Welcome to MageDelight Helloworld module')); return $resultPage; } } ?> Once you’ve pasted the code, it’s time we check the output via the following URL: http://domain.com/helloworld/index/index
  • 22. Page 20 Block file The block file will basically contain PHP view classes. So, let’s create a file name called helloworld.php inside app/code/ MageDelight/Helloworld/Block directory with the following code: <?php namespace MageDelightHelloworldBlock; class Helloworld extends MagentoFrameworkViewElementTemplate { public function __construct( MagentoFrameworkViewElementTemplateContext $context, array $data = [] ) { parent::__construct($context, $data); } public function getHelloworldData() { return 'MageDelight Helloworld block file call successfully'; } } ?> Front-end Layout File Now, we need to call block function as well as execute some design codes. So, let’s create a helloworld.html file inside the app/code/ MageDelight/Helloworld/view/frontend/templates directory and add the below code. <h3> <?php echo $block->getHelloworldData(); ?> </h3>
  • 23. Page 21 SUMMARY Magento plugins, extensions, & modules have become a critical part of all Magento 2 stores nowadays. Therefore, it is of utmost importance to leverage its power when building a Magento 2 store to both survive & thrive in today’s competitive market. That being said, whether you’re looking for the best Magento 2 Extensions in the market or need to build custom Magento 2 Extensions for specifically your online store, share your requirements with us & we promise to deliver 100% accurate & high quality according to your business requirements. Send an email to sales@magedelight.com or fill out the contact us form on our website and our expert consultants will get in touch with you within 24 hours.
  • 24. CONTACT US Harness Our High-end Magento Deliverables to Stay Abreast the Latest Trends Following eCommerce. Our team of experts will be happy to assist you. Details Available on www.magedelight.com For Queries, Write Us At.. sales@magedelight.com Call Us on 079 2644 7810