This article will show you the steps needed for creating a Magento 2 module. This module will output some content onto the frontend of the website.
When building a module, it is a good idea to put your application into developer mode. This can be done using one of the commands Magento gives you.
$ …
Creating a Magento 2 controller within a custom module will enable us to access a specific route on the storefront and perform some functionality. If you’re familiar with creating a controller in earlier versions, there are some differences when creating them in Magento 2.
Controllers in Magento 2 differ from Magento 1 as for every …
Similar to Magento 1, a fundamental task for developers within the newer versions of Magento is learning about creating a Magento 2 block.
The block classes will contain functionality that can be passed to Magento’s theme template files that can be shown on the storefront.
To add your own block, as always, is to …
A common task within Magento is to add layout updates to a custom module. These layout updates extend existing Magento layout configuration and can add additional template files to your storefront. This article will demonstrate adding Magento 2 module layout updates.
To start with, register a custom module that will hold your layout updates.
Create …
Magento 2 plugins are classes that can modify the behaviour of public class functions by running code before, after, or around that function call.
This means that any method’s behaviour can be modified within the application without the need to explicitly dispatch an event and create an observer like in Magento 1.
There is …
This article will help you understand how to rewrite an existing Magento 2 controller.
Similar to how blocks, helpers and models are rewritten, we can create our own module and add a preference within in the module’s di.xml file.
This article will show an example of how to override the Magento\Cms\Controller\Index\Index controller class. For simplicity, …
This article will help you understand how to rewrite an existing Magento 2 model. In earlier versions of Magento, you had to specify the rewrite within the module’s config.xml file. In Magento 2, this is done in the module’s di.xml file.
This article will show an example of how to override the Magento\Catalog\Model\Product class and …
This article will help you understand how to rewrite an existing Magento 2 helper. In earlier versions of Magento, you had to specify the rewrite within the module’s config.xml file. In Magento 2, this is done in the module’s di.xml file.
This article will show an example of how to override the Magento\Catalog\Helper\Data class and …
This article will help you understand how to rewrite an existing Magento 2 block. In earlier versions of Magento, you had to specify the rewrite within the module’s config.xml configuration file.
In Magento 2, this is done in the module’s di.xml file.
The example below will demonstrate how add a preference in order to …
Magento 2 Register Custom Module
Within Magento 2, we can create custom modules that are built on top of the original framework. Modules allow us to extend, override existing functionality or create new functionality altogether.
So how do we go about registering a module through Magento 2? Firstly, modules should belong in the app/code directory …