无法覆盖 Magento 1.7.0.2 中的结帐


Can't override Checkout in Magento 1.7.0.2

我似乎无法覆盖Magento中的结帐控制器。我在app/code/local/Checkout中复制了该文件夹,但它似乎不起作用。

其他只是复制粘贴文件夹的人似乎做对了。有什么需要做的吗?

这不是扩展控制器的推荐方法。我将假设您要扩展Checkout OnePageController。

正确的方法是。

1.) 确定正确的模块或为此创建一个新模块。

app/code/local/Mel/Gallosa (记得在app/etc/modules中激活模块)

添加文件等/配置.xml和控制器/一页控制器.php

您的文件内容将是

<?xml version="1.0"?>
<config>
    <modules>
        <Mel_Gallosa>
          <version>0.1.0</version>
        </Mel_Gallosa>
    </modules>
    <frontend>
        <routers>
            <checkout>
                <use>standard</use>
                <args>
                    <modules>
                        <Mel_Gallosa before="Mage_Checkout">Mel_Gallosa</Mel_Gallosa>
                    </modules>
                </args>
            </checkout>
        </routers>
    </frontend>
</config>

然后是新的控制器文件

<?php
require_once 'Mage/Checkout/controllers/OnepageController.php';
class Mel_Gallosa_OnepageController extends Mage_Checkout_OnepageController
{
    /*you can now overide any method here. Remember that you want to extend code in an Object Orientated fashion. Call the parent functions when appropriate and at the right time. Only replace methods that you are trying to overwrite. There is no need to dump all methods here. */
  //here is an example
  public function indexAction()
  {
      Mage::log('we have now overwritten the index action',null,'mel.log');
      parent::indexAction(); /* this means that if there are any core updates you will get them too :) */
  }
}

仅此而已。我的建议不是简单地复制文件夹。清楚地考虑一下你想做什么,并确保你以后不会做一些"可能会在你脚上开枪"的事情。保持OO机智!