Magento 1.7 - Overwrite system.xml

2019-08-06 19:34发布

问题:

I want to show a payment method only to specific customer groups, and therefore i want to add a config field in backend payment methods. I tried to overwrite the Mage_Payment system.xml in my custom module:

MyNamespace_OverwriteCfg.xml

<config>
    <modules>
        <MyNamespace_OverwriteCfg>
            <active>true</active>
            <codePool>local</codePool>
        </MyNamespace_OverwriteCfg>
    </modules>
</config>

system.xml:

<config>
<sections>
    <payment>
        <groups>
            <invoice>
                <fields>
                    <specificgroup translate="label">
                        <label>Payment on specific customer groups</label>
                        <frontend_type>multiselect</frontend_type>
                        <sort_order>51</sort_order>
                        <source_model>adminhtml/system_config_source_customer_group</source_model>
                        <show_in_default>1</show_in_default>
                        <show_in_website>1</show_in_website>
                        <show_in_store>1</show_in_store>
                    </specificgroup>
                </fields>
            </invoice>
        </groups>
    </payment>
</sections>
</config>

If i add this in the payment core system.xml it works fine, but i won't edit core files but overwriting won't work.

回答1:

The solution was, i simply had a mistake in my xml node structure. To add a field to "cash on delivery" of course it has to be like this:

<config>
   <sections>
        <payment>
            <groups>
                <cashondelivery> <!--Here was the mistake -->
                    <fields>
            //...
                    </fields>
                </cashondelivery> <!--Here was the mistake -->
            </groups>
         </payment>
    </sections>
</config>