2017-05-24 40 views
0

我試圖擴展我的Magento目錄ProductController視圖 (準確地說Mage_Checkout_CartController :: ViewAction)和Magento似乎沒有承認模塊擴展。爲什麼我的Magento Catalog ProductController沒有被擴展?

所以,我有以下文件:

這是/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 /設計/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 Catalog ProductController rewrite

多個attemps後,我後來發現這一點,並在這裏嘗試過的信息,雖然它是Magento的2

源2

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

回答

0

由於您嘗試覆蓋目錄模塊,則XML應如下所示:

<frontend> 
    <routers> 
     <catalog> 
+1

我編輯的文件/app/code/local/Mage/SwapMachine/etc/config.xml 具有模塊參考更換 和在管理清除高速緩存地區和代碼工作感謝你幫助我瞭解更多。 –

相關問題