dongtan9253 2012-11-06 11:32
浏览 20
已采纳

Magento:通过本地副本“覆盖”核心c​​onfig.xml文件? 它是否正确?

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?

  • 写回答

1条回答 默认 最新

  • dongza1708 2012-11-06 12:04
    关注

    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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 目详情-五一模拟赛详情页
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line