我想覆盖类Mage_Adminhtml_Catalog_CategoryController
(在Magento后台的类别控制器)。我认为我的config.xml是错误的地方,我怀疑是<to>
标签的问题。当我试图访问http://mywebsite/index.php/admin_k/catalog_category/index/key/somerandomkey/,我有一个404错误。
我的config.xml:
<?xml version="1.0"?>
<config>
<modules>
<Cheek_Lookbook>
<version>0.0.1</version>
</Cheek_Lookbook>
</modules>
<global>
<rewrite>
<cheek_lookbook_adminhtml_catalog_categorycontroller>
<from><![CDATA[#^/admin_k/catalog_category/#]]></from>
<to>/admin_k/lookbook/adminhtml_catalog_category/</to>
</cheek_lookbook_adminhtml_catalog_categorycontroller>
</rewrite>
<helpers>
<lookbook>
<class>Cheek_Lookbook_Helper</class>
</lookbook>
</helpers>
<blocks>
<lookbook>
<class>Cheek_Lookbook_Block</class>
</lookbook>
<adminhtml>
<rewrite>
<catalog_category_tab_product>Cheek_Lookbook_Block_Adminhtml_Catalog_Category_Tab_Product</catalog_category_tab_product>
</rewrite>
</adminhtml>
</blocks>
<resources>
<lookbook_setup>
<setup>
<module>Cheek_Lookbook</module>
</setup>
<connection>
<use>core_setup</use>
</connection>
</lookbook_setup>
<lookbook_write>
<connection>
<use>core_write</use>
</connection>
</lookbook_write>
<lookbook_read>
<connection>
<use>core_read</use>
</connection>
</lookbook_read>
</resources>
</global>
<admin>
<routers>
<lookbook>
<use>admin</use>
<args>
<module>Cheek_Lookbook</module>
<frontName>admin_lookbook</frontName>
</args>
</lookbook>
</routers>
</admin>
</config>
我已经尝试了很多方法(在URL中的/admin_k
后添加/lookbook/
,调整<to>
中的值...),但我不知道哪里出了问题。
下面是我的控制器类:
<?php
require_once "Mage/Adminhtml/controllers/Catalog/CategoryController.php";
class Cheek_Lookbook_Adminhtml_Catalog_CategoryController extends Mage_Adminhtml_Catalog_CategoryController {
public function postDispatch()
{
parent::postDispatch();
Mage::dispatchEvent('controller_action_postdispatch_adminhtml', array('controller_action' => $this));
}
public function indexAction()
{
Mage::log('There we aren't', null, 'someRandomLogs.log');
parent::indexAction();
}
}
有谁有主意吗?
1条答案
按热度按时间tzdcorbm1#
几天后,我终于明白为什么它不能正常工作了。
<rewrite> (...) <from> (...) <to> (...)
部分是一种老方法。在Magento 1.9.3中,如果你想覆盖一个adminhtml控制器,你必须这样做:
这是我个人的情况下,请找到一个“空”模板复制过去下面: