0

I am trying to add fields for configuration to stores in my Magento 2 application with my module that i am building.

The problem is I cant find any documentation on adding it to store. I can only find that it can be added to global configuration and that is not the place i want to have it.

So i want to find a way to make this happen this is my normal configuration for my general config.

<?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="mageplaza" translate="label" sortOrder="10">
            <label>Koppelingen</label>
        </tab>
        <section id="exact" translate="label" sortOrder="130" showInDefault="1" showInWebsite="1" showInStore="1">
            <class>separator-top</class>
            <label>Exact Online</label>
            <tab>mageplaza</tab>
            <resource>Mageplaza_HelloWorld::hello_configuration</resource>
            <group id="general" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
                <label>General Configuration</label>
                <field id="exact" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="0" showInStore="0">
                    <label>Id Of Exact</label>
                    <comment>Exact Online Id</comment>
                </field>
                <field id="display_text" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="0" showInStore="0">
                    <label>Secret Of Exact</label>
                    <comment>Exact Online Secret</comment>
                </field>
                <field id="base_url" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="0" showInStore="0">
                    <label>Base Url</label>
                    <comment>Base Url For Callback</comment>
                </field>
                <field id="project" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="0" showInStore="0">
                    <label>Project</label>
                    <comment>The place to fill in your project for the store</comment>
                </field>
            </group>
        </section>
    </system>
</config>
0

This updated system.xml file is what you have to use:

<?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="mageplaza" translate="label" sortOrder="10">
        <label>Koppelingen</label>
    </tab>
    <section id="exact" translate="label" sortOrder="130" showInDefault="1" showInWebsite="1" showInStore="1">
        <class>separator-top</class>
        <label>Exact Online</label>
        <tab>mageplaza</tab>
        <resource>Mageplaza_HelloWorld::hello_configuration</resource>
        <group id="general" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
            <label>General Configuration</label>
            <field id="exact" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
                <label>Id Of Exact</label>
                <comment>Exact Online Id</comment>
            </field>
            <field id="display_text" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
                <label>Secret Of Exact</label>
                <comment>Exact Online Secret</comment>
            </field>
            <field id="base_url" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
                <label>Base Url</label>
                <comment>Base Url For Callback</comment>
            </field>
            <field id="project" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
                <label>Project</label>
                <comment>The place to fill in your project for the store</comment>
            </field>
        </group>
    </section>
</system>

It will enable configuration on all levels: Global, Website and Store.

0

change showInStore="0" to showInStore="1" on field and group level for it to display on store scope.

From the XML-schema we can see that you define with integer 1/0 the visibility level of your configuration setting. In your case the section attribute showInDefault,showInWebsite and showInStore is the only one set to 1, so section will display on store scope but not the individual field configuration settings.

https://github.com/magento/magento2/blob/develop/app/code/Magento/Config/etc/system.xsd#L61

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.