How to Set Default Values for Magento 2 System Configuration

Let me tell you scenario where you are delivering a Magento 2 custom developed module to a store merchant who is a Magento 2 newbie. For the extension to work as expected, certain configurations are meant to have particular values. But the store merchant or admin may not be aware of it or may not have an idea of which value should be added to get the desired output. To ease the configuration and avoid empty value output, you can set default values for Magento 2 system configuration.

By setting default values for Magento 2 system configuration, you ensure that there will always be a logical value returned for the configuration option and not have to worry about an invalid or empty output. As soon as the extension is installed, the Magento 2 system configuration is set to the default values. It makes the task of admin/module user easier.

The post shows the method to set default values for Magento 2 system configuration.

Method to Set Default Values for Magento 2 System Configuration:

  • Your system.xml file will be something like this:
  • Create Config.xml at Vendor\Extension\etc\ directory

Follow the above method and leave no chance to entertain the newbies who use your extension with complaints due to their lack of knowledge in extension configuration!

Please use the Comments section below to mention your doubts about the topic. I’d be happy to help.

Thank you.

5
(based on 12 Reviews)
How to Set Default Values for Magento 2 System ConfigurationAuthor Magento Badge

Sanjay Jethva

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.

1 Comment

Leave a Reply

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