繁体   English   中英

为什么未扩展我的Magento目录ProductController?

[英]Why is my Magento Catalog ProductController not being extended?

我正在尝试扩展我的Magento目录ProductController视图(准确地说是Mage_Checkout_CartController :: ViewAction),而Magento似乎并​​未认可该模块扩展。

所以我有以下文件:

这是/app/code/local/Mage/SwapMachine/etc/config.xml配置文件

    <?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <Mage_SwapMachine>
            <version>0.1.0</version>
        </Mage_SwapMachine>
    </modules>
    <frontend>
        <routers>
            <swapmachine>
                <args>
                    <modules>
                        <Mage_SwapMachine before="Mage_Catalog">Mage_SwapMachine_Frontend</Mage_SwapMachine>
                    </modules>
                </args>
            </swapmachine>
        </routers>
    </frontend>
</config> 

这是/app/design/frontend/base/default/layout/swapmachine.xml文件。 指示我从源代码2创建(源代码在底部)

<?xml version="1.0"?>
<mage_swapmachine_frontend>
    <update handle="catalog_product_view"/>           
</mage_swapmachine_frontend>

这是/app/code/local/Mage/SwapMachine/controllers/Frontend/ProductController.php文件

    <?php
    include(Mage::getBaseDir()."/app/code/core/Mage/Catalog/controllers/ProductController.php");

class Mage_SwapMachine_Frontend_ProductController extends Mage_Catalog_ProductController
{

    public function viewAction()
    {
       /// Get initial data from request
        die("IT'S WORKING!");
    }

}

我已经尝试了一个星期来自行解决这种情况,但我感到迷失了。 我首先关注这里的信息。

来源1

Magento目录ProductController重写

经过多次尝试后,我后来发现了这一点,并尝试了此处的信息,尽管它是针对Magento 2的。

来源2

https://magento2.atlassian.net/wiki/display/m1wiki/How+To+Overload+a+Controller

在尝试覆盖目录模块时,XML应该如下所示:

<frontend>
    <routers>
        <catalog>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM