Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento: "overriding" core config.xml files via a local copy? Is this correct?

Tags:

php

magento

I'm trying to rename some of the credit cards which appear on my Magento checkout (e.g. "Visa" becomes "Visa Debit/Credit").

To do this, I discovered you must edit the names as defined in /app/code/core/Mage/Payment/etc/config.xml.

Not wanting to overwrite core files, I tried copying this file to /app/code/local/Mage/Payment/etc/config.xml and making my changes there, but it didn't work. From research, I gather than Magento doesn't autoload config files from local folders first?

I then discovered that you could change app/etc/modules/Mage_All.xml and specify <codePool>local</codePool> instead of <codePool>core</codePool> under <Mage_Payment>. My changes made under the local folder would then work.

Is this the correct approach? Will changing the codePool of a core module have any repercussions? Is there some other way to "override" a core module's config.xml?

like image 629
WackGet Avatar asked Nov 06 '12 11:11

WackGet


1 Answers

You have to create a new module under local : Yourcompany_Payment

In this module, define a minimalist etc/config.xml with the XML rewrite you need :

<config>
    <modules>
        <Yourcompany_Payment>
            <version>0.1.0.0</version>
        </Yourcompany_Payment>
    </modules>
    <global>
        <payment>
            <cc>
                <types>
                    <AE>
                        <code>AE</code>
                        <name>American Express</name>
                        <order>0</order>
                    </AE> [...]

And then in the app/etc/modules folder, add a new Yourcompany_Payment.xml (or Yourcompany_All.xml) with :

<config>
    <modules>
        <Yourcompany_Payment>
            <active>true</active>
            <codePool>local</codePool>
            <depends>
                <Mage_Payment/>
            </depends>
        </Yourcompany_Payment>
    </modules>
</config>

The depends node is vital because it will tell magento to load your XML after magento's one in order to your rewrite to work

like image 177
Jscti Avatar answered Sep 25 '22 22:09

Jscti