How to add Custom Catalog Input Type Using Observer In Magento 2

Considering the available CMS’s available for eCommerce, Magento has still remained as the first pick for store owner whether it is small or large scale. Due to its flexible architecture, it allows us to customize the Magento according to our Business needs by extending the Native code. Magento owns different observers generally known as “listener”, that helps you to detect specific events and in response to that execute specific action using code. Compared to Magento 1, Magento 2 have the pretty well-integrated observer system.
Magento Custom Development is our favorite part where we used to create and play with code. Recently, we came across such a requirement where the customer wants to add his own Input type in Magento 2 backend. After working on the client’s requirement for some time, finally, we were ready with our code for adding Custom Catalog Input Type Using Observer In Magento 2.

In the first step, we need to create “events.xml” file at this path.app\code\Vendor\Extension\etc\adminhtml\events.xml

1

<!--?xml version="1.0"?-->

Now, in second step, we need to add custom option type using “Config.xml” file at below path.app\code\Vendor\Extension\etc\config.xml

1

2

3

4

5

6

7

<!--?xml version="1.0"?-->

{custom type}

In this third and last step, we need to create one more file to add our option to input type dropdown. For that purpose, we need to create “AddCustomAttributeType.php” file at this path.app\code\Vendor\Extension\Observer\AddCustomAttributeType.php