Sergiy Vasyutynsky Avatar

After reading Atwix blog you should know a lot about Magento System Configuration, especially how to create tabs and sections, groups and fields, etc. In this article we’ve described how to customize all this things in the configuration file.

As you should already know, for creating own tab, section, group or field we need to use the system.xml file. So, let’s try to customize System Configuration elements in it.

For example, we need to do the following steps:

1. Tab ‘Catalog’ – move to the top.
2. Section ‘General’ – change a label in ‘General Information’.
3. Group ‘Store Information’ (section ‘General’) – add a new field ‘Show VAT Number’ (dropdown yes/no).
4. Fields ‘VAT Number’ and ‘Validate VAT Number’ – add them dependence on the ‘Show VAT Number’ field.
5. Section ‘Moneybookers’ – change a label in ‘Phoenix Moneybookers’.

Now, create a new module ‘SystemConfig’ for experiments, here is the initial and module configuration files:

app/etc/modules/Atwix_SystemConfig.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Atwix_SystemConfig>
            <active>true</active>
            <codePool>local</codePool>
        </Atwix_SystemConfig>
    </modules>
</config>

app/code/local/Atwix/SystemConfig/etc/config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Atwix_SystemConfig>
            <version>1.0.0</version>
        </Atwix_SystemConfig>
    </modules>
</config>

Also, note please – in the system configuration file we should put nodes of those elements (tabs, sections, groups, fields) that are also needed to be changed:

app/code/local/Atwix/SystemConfig/etc/system.xml

<?xml version="1.0"?>
<config>
    <tabs>
        <!-- 1 -->
        <catalog>
            <sort_order>1</sort_order>
        </catalog>
    </tabs>

    <sections>
        <general>
            <!-- 2 -->
            <label>General Information</label>
            <groups>
                <store_information>
                    <fields>
                        <!-- 3 -->
                        <show_vat>
                            <label>Show VAT Number</label>
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                            <sort_order>26</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </show_vat>
                        <!-- 4 -->
                        <merchant_vat_number>
                            <depends>
                                <show_vat>1</show_vat>
                            </depends>
                        </merchant_vat_number>
                        <validate_vat_number>
                            <depends>
                                <show_vat>1</show_vat>
                            </depends>
                        </validate_vat_number>
                    </fields>
                </store_information>
            </groups>
        </general>
        <!--5-->
        <moneybookers>
            <label>Phoenix Moneybookers</label>
        </moneybookers>
    </sections>
</config>

After all, let’s check what we have:

Example

Example2

As you can see, everything works fine except the last task, what means that in the ‘Moneybookers’ section the label wasn’t changed. Besides that, we did not get the desired result, because system configuration file app\code\community\Phoenix\Moneybookers\etc\system.xml has loaded only after our file app/code/local/Atwix/SystemConfig/etc/system.xml and our values were overwritten. Therefore, for solving this problem we can choose one of the following options:

1. First, add ‘depends’ function to our initial configuration files:

app/etc/modules/Atwix_SystemConfig.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Atwix_SystemConfig>
            <active>true</active>
            <codePool>local</codePool>
            <depends>
                <Phoenix_Moneybookers/>
            </depends>
        </Atwix_SystemConfig>
    </modules>
</config>

2. Or, you can create a new module with namespace that will take position after Phoenix namespace in alphabetical order.
3. Make change using the observer.
This post might help if you`ll face the similar situation. However, if you have any ideas or suggestions we would be glad to accept them. Comments are most welcome!