2013-08-02 58 views
1

我想从本地模块”覆盖“社区”控制器覆盖社区控制器。我发现很多教程了解重写核心控制器而是一个社区控制器罢了。的Magento从本地模块

的Magento版本:1.6.1

我现在的状态是: - 覆盖核心控制器=> OK - 覆盖社区控制器=> KO

这是我的文件树:

- community 
    - Namespace 
    - Mycommunitymodule 
     - controllers 
     - IndexController.php 
- local 
    - Namespace 
    - Mylocalmodule 
     - controllers 
     - Mycommunitymodule 
      - IndexController.php 
     - etc 
     - config.xml 

我的本地模块的源我overrided控制器

<mycommunitymodule> 
    <args> 
    <modules> 
    <Namespace_Mylocalmodule before="Namespace_Mycommunitymodule">Namespace_Mylocalmodule_Mycommunitymodule</Namespace_Mylocalmodule> 
    </modules> 
    </args> 
</mycommunitymodule> 

源代码:

<? 
$origDir = Mage::getModuleDir('controllers','Namespace_Mycommunitymodule').DS; 
require_once $origDir.'IndexController.php'; 
class Namespace_Mylocalmodule_Mycommunitymodule_IndexController extends  Namespace_Mycommunitymodule_IndexController 
{ 
public function indexAction() { 
     zend_Debug::Dump("test surchargé"); 
} 
} 

预先感谢您

回答

0

看起来几乎是正确的。 尝试通过更换

<Namespace_Mylocalmodule before="Namespace_Mycommunitymodule">Namespace_Mylocalmodule_Mycommunitymodule</Namespace_Mylocalmodule> 

通过

<Namespace_Mylocalmodule before="Namespace_Mycommunitymodule">Namespace_Mylocalmodule</Namespace_Mylocalmodule> 

和类名Namespace_Mylocalmodule_Mycommunitymodule_IndexController Namespace_Mylocalmodule_IndexController因为如果需要的话它的文件名和文件夹。