Is it possible to append a system configuration to existing configuration section group via a custom module

magento.stackexchange https://magento.stackexchange.com/questions/333592

Question

I've tried to add a configuration item to sales/carriers/fedex in my custom moduel, but seems not work

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
    <system>
        <section id="carriers">
            <group id="fedex" type="" sortOrder="60" showInDefault="1" showInWebsite="1" showInStore="1" translate="label">
                <label>Fedex test append</label>
                <field id="test" translate="label" sortOrder="1" type="select" showInDefault="1" showInWebsite="1" showInStore="0">
                    <label>Enabled</label>
                    <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                </field>
            </group>
        </section>
    </system>
</config>

Are there any ways to do that?

Was it helpful?

Solution

Yes, you can. Step 1: add Magento_Fedex module sequence into your module.xml

<module name="Namespace_ModuleName" setup_version="2.0.2" >
    <sequence>
        <module name="Magento_Fedex"/>
    </sequence>
</module>

Step 2: Your system.xml define exactly construct like Magento_Fedex::system.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
    <system>
        <section id="carriers">
            <group id="fedex">
                <field id="test" translate="label" sortOrder="1" type="select" showInDefault="1" showInWebsite="1" showInStore="0">
                    <label>Enabled</label>
                    <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                </field>
            </group>
        </section>
    </system>
</config>

Step 3: run bin/magento setup:upgrade

OTHER TIPS

Don't forget the system.xml file goes into Vendor/Module/etc/adminhtml

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top