How to overwrite system.xml file in Magento

At times we need to add new configurations options or modify some option in an existing module, lets see how to do it in this article. Suppose we have to add a new field “Surcharge” to the Payment Method “Cash on Delivery” configuration options and modify the “Instructions” option label to “Message”.

To do this we have to create a new module.

1. We create a file “Techawaken_Cod.xml” in folder app\etc\modules\ to declare the module. The content of the file is shown below:


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

2. Next we create the module folder structure app\code\local\Techawaken\Cod\etc\

3. Now create a system.xml file in the folder app\code\local\Techawaken\Cod\etc\ with the following contents


<?xml version="1.0"?>
<config>
<sections>
<payment translate="label" module="payment">
<groups>
<cashondelivery translate="label">
<fields>
<surcharge translate="label">
<label>Surcharge</label>
<frontend_type>text</frontend_type>
<sort_order>62</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</surcharge>
<instructions translate="label">
<label>Message</label>
<frontend_type>textarea</frontend_type>
<sort_order>62</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</instructions>
</fields>
</cashondelivery>
</groups>
</payment>
</sections>
</config>

The original configuration options for the “Cash On Delivery Payment” method are defined in system.xml file located at app\code\core\Mage\Payment\etc\. Compare the <cashondelivery>  group with the above code to study the changes made.

4. Now flush the caches and reload the admin configuration page, you will notice the changes/additions made.

If you do not want to create a new module then you can skip step 1 and add the code mentioned in step 3 above to system.xml file of some custom module already created.

Leave a Comment

Back to top