18

i wanted some customization in admin panel so i have made changes in

   1) "app/code/core/../system.xml file its working fine. 

But I don't want to change code inside core folder. Because of my version change.

So i like to move that file into my local folder but its not working

 2) "app/code/local/../system.xml" files is not working

Can anyone please guide me how to override system.xml file?

Thanks

1 Answer 1

30

For the system.xml files it doesn't work like it does for class files. The system.xml files are collected from the active modules of Magento. Just copying one in local folder it doesn't mean it's in a module, because the module declaration file still says that the module belongs to the core codepool.
If you want to add new fields to a section or override some of the fields you need to create you own module.
Here is an example of how you can add a new field in the section Catalog->Frontend and how you can override one in the same section.
Let's say that your module is called Easylife_Catalog.
You will need the following files:
app/etc/modules/Easylife_Catalog.xml - the declaration file

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

app/code/local/Easylife/Catalog/etc/config.xml - the configuration file

<?xml version="1.0"?>
<config>
    <modules>
        <Easylife_Catalog>
            <version>0.0.1</version>
        </Easylife_Catalog>
    </modules>
</config>

app/etc/local/Easylife/Catalog/etc/system.xml - system->configuration file
Let's say you want to change the List Mode field to be available only at global level (no website and store view level). The setting path is catalog/frontend/list_mode. Then the system.xml will look like this:

<?xml version="1.0"?>
<config>
    <sections>
        <catalog><!-- first part of the path -->
            <groups>
                <frontend><!-- second part of the path -->
                    <fields>
                        <list_mode><!-- third part of the path -->
                            <show_in_website>0</show_in_website><!-- this will override the core value -->
                            <show_in_store>0</show_in_store><!-- this will override the core value -->
                        </list_mode>
                    </fields>
                </frontend>
            </groups>
        </catalog>
    </sections>
</config>

Now let's say you want to add a new field called custom in the same config section. Now the xml above becomes

<?xml version="1.0"?>
<config>
    <sections>
        <catalog><!-- first part of the path -->
            <groups>
                <frontend><!-- second part of the path -->
                    <fields>
                        <list_mode><!-- third part of the path -->
                            <show_in_website>0</show_in_website><!-- this will override the core value -->
                            <show_in_store>0</show_in_store><!-- this will override the core value -->
                        </list_mode>
                        <custom translate="label"><!-- your new field -->
                            <label>Custom</label>
                            <frontend_type>text</frontend_type>
                            <sort_order>1000</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </custom>
                    </fields>
                </frontend>
            </groups>
        </catalog>
    </sections>
</config>

I don't know if there is a method to remove some field from the configuration using this method. I looked for it but didn't find anything.

3
  • Thanks. I have only little note, tag <depends> is not necessary, because local modules are always loaded after core modules. Commented Mar 3, 2016 at 8:39
  • 2
    @JiříChmiel. Ehum...no they are not. all the module declaration files (app/etc/modules) are loaded, then all the <depends> tags are parsed and an hierarchy of modules is established. then the modules are loaded in that order.
    – Marius
    Commented Mar 3, 2016 at 8:53
  • Thanks for the great answer. For me, the <depends> in the app/etc/modules/Easylife_Catalog.xml is what I was missing. Without that it seemed to favor the core system.xml file over the changes in my local system.xml file for modifying declarations.
    – PromInc
    Commented Aug 11, 2016 at 19:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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