How to Create System.xml Configuration In Magento 2

19 Aug, 2021

Today I am going to show you how we can add custom configuration Magento 2 backend

If we create our custom module then we need to add our custom configuration in Magento backend. Need to create only one file for create our custom configuration in backend

Let's create custom banckend configuration file

	
	<?xml version="1.0"?>
<!-- file path: MAGENTO_ROOT/app/code/Vendorname/Modulename/etc/adminhtml/system.xml -->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
    <system>
        <tab id="vendorname_id" translate="label" class="vendor" sortOrder="100">
            <label>Your vendor title</label>
        </tab>
        <section id="module_id" translate="label" type="text" sortOrder="40" showInDefault="1" showInWebsite="1"
                 showInStore="1">
            <class>separator-top</class>
            <label>Module Title</label>
            <tab>vendorname_id</tab>
            <resource>Vendorname_Modulename::modulename_config</resource>
            <group id="general" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1"
                   showInStore="1">
                <label>Configuration</label>
                <field id="enable" translate="label comment" type="select" sortOrder="10" showInDefault="1"
                       showInWebsite="1" showInStore="1">
                    <label>Enable</label>
                    <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                </field>
            </group>
        </section>    
    </system>
</config>

That's code for create custom configuration in Magento 2 backend

RAJU SADADIYA (MAGENTO DEVELOPER)