Right here is the methods you will comply with  this How to create Magento 2 widget?:
  1. File setup/Our module
  2. Widget declaration File
  3. Let’s create the model file
  4. Let’s create the block file
  5. Create the template file

Previously on our general Tutorial of How to use Magento 2 CMS (Content Management System), we already have a good time with basic knowledge of using this powerful feature. Now we will go  down in detail with the Magento 2 Widget inside it.

Magento 2 widget will allow the site administrator to insert admin contact information such as full name, age, gender….etc. And you can create Magento 2 widget via Widget Instance or add in the editor section of CMS Page => Block. We’ll use common field types in Magento 2 widgets such as text and dropdown.

I assume that you’ll familiar with the structure of the Magento 2 module. So let’s start:

First, let’s take a look at the main structure which we’ll need to implement for our custom Magento 2 widget.

1 File setup/Our module
2 Widget declaration File
3 let’s create the model file
4 let’s create the block file
5 create the template file

app/code/Magestore/CustomWidget/etc/module.xml: file setup of our module
app/code/Magestore/CustomWidget/etc/widget.xml: a widget declaration file used to declare widget information and parameters.

File setup/Our module

First we need create the module setup file. Create file app/code/Magestore/CustomWidget/etc/module.xml and paste the following contents in that file. We have used Magestore as our module Vendor Name and CustomWidget as our module name.

Widget declaration File

Create the widget file app/code/Magestore/CustomWidget/etc/widget.xml with content

We also contribute great content of Magento Tutorial for Magento 1.x.

DON'T MISS THE CHANCE!

magento tutorial

How to Use Magento 2 CMS (Content Management System)
How To Call a Static Block On CMC Page

Leave a Reply

Your email address will not be published. Required fields are marked *