【发布时间】:2015-10-02 13:40:19
【问题描述】:
我需要覆盖code/core/Mage/ProductAlert/controllers 的AddController.php 中的stockAction()。所以我搜索了很多以了解如何进行,并得到了这个:
/etc/modules/Totem_ProductAlert.xml
<?xml version="1.0"?>
<config>
<modules>
<Totem_ProductAlert>
<active>true</active>
<codepool>local</codepool>
</Totem_ProductAlert>
</modules>
</config>
/code/local/Totem/ProductAlert/etc/config.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Totem_ProductAlert>
<version>0.0.1</version>
</Totem_ProductAlert>
</modules>
<frontend>
<routers>
<productalert>
<args>
<modules>
<Totem_ProductAlert before="Mage_ProductAlert">Totem_ProductAlert</Totem_ProductAlert>
</modules>
</args>
</productalert>
</routers>
</frontend>
</config>
/code/local/Totem/ProductAlert/controllers/AddController.php
class Totem_ProductAlert_AddController extends Mage_ProductAlert_AddController
{
public function stockAction()
{
Mage::log('test', null, 'Test.log');
}
但该操作未被覆盖,也没有创建任何 Test.log。
有人知道我在哪里搞砸了吗?
谢谢。
【问题讨论】:
-
/code/local/Totem/ProductAlert/controllers/AddController.php 是否包含对您要覆盖的 Mage 核心文件的引用?即 require_once Mage::getModuleDir('controllers', 'Mage_Product_Alert').DS.'AddController.php'; - 你确定你的模块正在加载吗? (清除缓存,添加 die() 等?)
-
是的:
require_once Mage::getModuleDir('controllers', 'Mage_ProductAlert').DS.'AddController.php';缓存已禁用,我如何确定我的模块已加载? (出现在System > Configuration > Advanced > Advanced)
标签: php magento magento-1.8