[英]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!");
}
}
我已經嘗試了一個星期來自行解決這種情況,但我感到迷失了。 我首先關注這里的信息。
經過多次嘗試后,我后來發現了這一點,並嘗試了此處的信息,盡管它是針對Magento 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.