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.

Get Weekly Updates

Never miss Magento tips, tricks, tutorials, and news.

Thank you for subscribing.

Something went wrong.

4.7
(based on 19 Reviews)

Sanjay is a co-founder at Meetanshi. He is a Certified Magento Developer who loves creating Magento E-commerce solutions. Owing to his contributions in Magento Forums and posting solutions, he is among the top 50 contributors of the Magento community in 2019. When he is not engrossed with anything related to Magento, he loves to play cricket.

8 comments On How to Add Custom Button in Magento 2 System Configuration

Leave a reply:

Your email address will not be published.