Reading list Switch to dark mode

    Magento2 : How to add custom module configuration in configuration section using system.xml

    Updated 22 February 2024

    Magento2 : How to add custom module configuration in configuration section using system.xml
    Here we learn that how to add custom module  configuration in Magento2

    Basic structure and location of system.xml file

    for custom module configuration  we need to create system.xml  in  app/code/Namespace/Modulename/etc/adminhtml

    <?xml version="1.0"?>
    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../Config/etc/system_file.xsd">
        
    </config>
     

    Above written code is common of each system.xml file. This is basic structure of system.xml.

    For add new tab in configuration section

    Start your headless eCommerce
    now.
    Find out More
    <?xml version="1.0"?>
    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../Config/etc/system_file.xsd">
        <system>
            <!-- for add new tab in Magento2 system configuration section -->
    	    <tab id="webkul" translate="label" sortOrder="10">
                 <label>Webkul</label>
            </tab>
        </system>
    </config>
      

    For add new configuration section with group and fields.

    <?xml version="1.0"?>
    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../Config/etc/system_file.xsd">
        <system>
            <!-- for add new tab in Magento2 system configuration section -->
    	    <tab id="webkul" translate="label" sortOrder="10">
                 <label>Webkul</label>
            </tab>
            <!-- for create section -->
            <section id="sleekaccordian" translate="label" type="text" sortOrder="320" showInDefault="1" showInWebsite="1" showInStore="1">
                <label>Sleek Accordian</label>
                <!-- Assign section to tab -->
                <tab>webkul</tab>
                <resource>Webkul_Sleekaccordian::configuration</resource>
                <!-- create group for fields in section -->
                <group id="parameters" translate="label" type="text" sortOrder="5" showInDefault="1" showInWebsite="1" showInStore="1">
                    <label>Parameters</label>
                    <!-- create text type field -->
                    <field id="slide_speed" translate="label comment" sortOrder="7" type="text" showInDefault="1" showInWebsite="1" showInStore="1">
                        <label>Slide Speed</label>
                        <comment>e.g 800 .</comment>
                        <validate>validate-number required-entry</validate>
                    </field>
                </group>
            </section>
        </system>
    </config>
     

    After these your module configuration tab, section, group and field created in store configuration for check goes to store configuration (Store->Configuration) and you get your module configuration section as following

    Selection_024

    . . .

    Leave a Comment

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


    Be the first to comment.

    Back to Top

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home