4.7 (93.64%) 22 votes


To Create and Use Configuration in Magento 2 you need to follow:

  1. Step 1: Create system.xml file
  2. Step 2: Set default configuration value
  3. Step 3: Set data for select configuration
  4. Step 4: Use configurations

Magento 2 provides configuration system in backend. It stores some settings of your extensions which can be changed by admin. You can go to Store -> Setting -> Configuration -> [your_extension] to see them. This topic will show you how to create a configuration file for “Magestore_CustomSetting” extension and use it.

Step 1: Create system.xml file

File directory: app/code/Magestore/CustomSetting/etc/adminhtml/system.xml

In above example, we created 2 configuration like 2 fields in “general” group, customsetting section and magestore tab. There are some fields in a group, some groups in a section, some sections in a tab.

Tab elements:

  • id: each tab is defined by an id (unique)
  • label: title of tab

Section elements:

  • Label: Title of this section
  • Tab: it’s tab_id which is place to display this configuration
  • Resource: defined the ACL rule to access this configuration
  • Group: define a group of some configurations.
  • Fields: the main path of this page.

Field elements:

  • Label: Title of this field
  • id: field’s path
  • Type: there are some field type: text, select, multiselect…
  • source_model: store data of this field, we can use it for select, multiselect type.
  • showInDefault, showInWebsite, showInStore: configuration’s scope.


Step 2: Setup default value

File: app/code/Magestore/CustomSetting/etc/adminhtml/config.xml

Step 3: Set data for select configuration

If we want to set special data for a select or multiselect configuration we can use

Source_model element.

Step 4: Use configuration


The 4 steps I mention above is the shortest process for you to Create and Use Configuration in Magento 2. With this guide, you can manage the Configuration in Magento 2 easily. Every store has a Configuration in Magento 2 with many attributes.

Thank you for reading this post and see you in other posts from Magestore!

How to Check ACL Permission in Magento 2
How to Create Admin Menu in Magento 2