At the time of creating new extension in Magento 2, you need to provide admin user with some settings prior to make it work. System.xml is a configuration file which is used to create those setting fields in extension and it is placed under “etc” folder. After the successful creation of settings, these fields are shown under Store –> Configuration –> Your Extension.

Here, we will learn to create system.xml configuration in Magento 2.

Go to app/code/Magecomp/Hello/etc/adminhtml/system.xml and add the code below:

With above code, we can add new tab, section, group and field. Now the next step is to set default values for these configuration item, create the file app/code/Magecomp/Hello/etc/config.xml and add the code below:

There is another important thing to do is to setup ACL. In our system.xml, we have the line
Magecomp_First::test_config
This is used to setup ACL for system configuration. Create a file app/code/Magecomp/Hello/etc/acl.xml with below code:

Now open Magento admin and you can see the HelloWorld tab and sections.

Hope this tutorial has helped you to create system.xml configuration for your next Magento 2 extension.

Let me know if you stuck somewhere or require any help regarding through commenting. I will be happy to help you.

Click to rate this post!
[Total: 9 Average: 5]