Mage Check Facebook iconFacebook MAGE CHECK Mage Check Linkedin iconLinkedin MAGE CHECK Mage Check Skype iconSkype MAGE CHECK

Magento How to Create System Configuration Section

$ The system.xml is a configuration file which is used to create configuration fields in Magento 2 System Configuration.

$ You will need this if your module has some settings which the admin needs to set. You can go to Store -> Setting -> Configuration to check how it looks like.

Step 1: Create system.xml

Magento 1

<?xml version='1.0'?> <config> <modules> <MageCheck_SystemConfig> <version>1.0.0</version> </MageCheck_SystemConfig> </modules> </config>

File path: app/code/local/MageCheck/SystemConfig/etc/config.xml

Magento 2

<?xml version='1.0'?> <config xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='urn:magento:module:Magento_Config:etc/system_file.xsd'> <system> <tab id='magecheck' translate='label' sortOrder='10'> <label>MageCheck</label> </tab> <section id='tutorial' translate='label' sortOrder='130' showInDefault='1' showInWebsite='1' showInStore='1'> <class>separator-top</class> <label>Tutorial</label> <tab>magecheck</tab> <resource>MageCheck_Tutorial::tutorial_config</resource> <group id='general' translate='label' type='text' sortOrder='10' showInDefault='1' showInWebsite='0' showInStore='0'> <label>General Configuration</label> <field id='enable' translate='label' type='select' sortOrder='1' showInDefault='1' showInWebsite='0' showInStore='0'> <label>Module Enable</label> <source_model>Magento\Config\Model\Config\Source\Yesno</source_model> </field> <field id='display_text' translate='label' type='text' sortOrder='1' showInDefault='1' showInWebsite='0' showInStore='0'> <label>Display Text</label> <comment>This text will display on the frontend.</comment> </field> </group> </section> </system> </config>

File path: app/code/MageCheck/Tutorial/etc/adminhtml/system.xml

Step 2: Create config.xml

Magento 1

<?xml version='1.0'?> <config> <tabs> <catalog> <sort_order>1</sort_order> </catalog> </tabs> <sections> <general> <label>MageCheck</label> <groups> <store_information> <fields> <show_tutorial> <label>Tutorial</label> <frontend_type>select</frontend_type> <source_model>adminhtml/ system_config_source_yesno</source_model> <sort_order>26</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> </show_tutorial> </fields> </store_information> </groups> </general> <tutorial> <label>Tutorial</label> </tutorial> </sections> </config>

File path: app/code/local/MageCheck/SystemConfig/etc/system.xml

Magento 2

<?xml version='1.0'?> <config xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='urn:magento:module:Magento_Store:etc/config.xsd'> <default> <tutorial> <general> <enable>1</enable> <display_text>Tutorial</display_text> </general> </tutorial> </default> </config>

File path: app/code/MageCheck/Tutorial/etc/config.xml

Step 3: Flush Cache

Magento 1

Log in to you Magento 1 Admin panel, go to System -> Cache management and flush your magento cache.

Magento 2

The last thing you have to do is to clean and flush your Magento cache:

php bin/magento cache:clean
php bin/magento cache:flush

This is the sample way to create a System Configuration Section in Magento!

Contact us

Have you decided on an online Business Plan website?