How to Add Custom Button in Magento 2 System Configuration

How to Add Custom Button in Magento 2 System Configuration

While developing a Magento 2 extension, you have to follow various requirements and one such that I’m posting the solution for is to add custom button in Magento 2 system configuration.

You would want to create a button in the Magento 2 system configuration for custom functionality or perform an action. For example, call a Helper function or controller action.

I had used this solution to create a button that generates a CSV file for product attributes as shown here:

Add Custom Button in Magento 2 System Configuration

Check the solution below and do let me know how it was useful to you.

Steps to Add Custom Button in Magento 2 System Configuration:

  1. Create field in [Vendor]\[Module]\etc\adminhtml\system.xml file

  2. Create Button.php file in [Vendor]\[Module]\Block\System\Config

  3. Create button.phtml file in [Vendor]\[Module]\view\adminhtml\templates\system\config

That was all about creating a button in system configuration in Magento 2 for custom functionality.

Any doubts yet? Please share them in the Comments section below and I’d be happy to help.

Feel free to share the above solution with fellow developers.

Thanks.

5
(based on 6 Reviews)

Sanjay is a co-founder at Meetanshi. He is a certified Magento developer who loves creating Magento E-commerce solutions. When he is not engrossed with anything related to Magento, he loves to play cricket.

Leave a Reply