Override block in magento 2

Page 1

How to Override Block in Magento 2


I am going to teach you how to override blocks in Magento 2, but before starting the tutorial, let’s understand what a block is ? PHP classes is used to create a link between templates and layout known as Blocks. Class is a se of methods that handles and control the Magento UI Blocks. Also it has the following features : 

A block can have more blocks.

A block can be utilize in different pages and blocks.


You need to create a custom module to override block in Magento 2 and after that you will do the following things : 

Create directories

Configure Module

Register Module

Override di.xml File

Override Contact Form

Override contact_index_index.xml

Override form.phtml

Run Commands


You can view the codes of the mentioned steps here at How to Override Block in Magento 2


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.