问题描述
我正在编写一个Magento扩展,试图覆盖第三方扩展IndexController.php
,但是Magento无法识别它.
I am writing a Magento extension that is trying to override a third party extensions IndexController.php
but Magento does not recognize it.
我有一个与此问题类似的问题,并且我有尝试过Benmarks的建议,但Magento仍然似乎忽略了我的替代.
I have a similar issue as this question and I have tried benmarks suggestions but Magento still seems to be ignoring my override.
我的config.xml
文件如下所示:
<?xml version="1.0"?>
<config>
<modules>
<Mycompany_Stores>
<version>0.1.0</version>
</Mycompany_Stores>
</modules>
<frontend>
<routers>
<storepickup>
<args>
<modules>
<Mycompany_Stores before="Magestore_Storepickup">Mycompany_Stores</Mycompany_Stores>
</modules>
</args>
</storepickup>
</routers>
</frontend>
</config>
我的IndexController.php
看起来像这样:
<?php
require_once('Magestore/Storepickup/controllers/IndexController.php');
class Mycompany_Stores_IndexController extends Magestore_Storepickup_IndexController {
public function indexAction() {
var_dump('asdfasdfsdf');
parent::indexAction();
}
}
在上面链接文章中的第一个建议之后,我得到一个错误:Fatal error: Uncaught exception 'Exception' with message 'Warning: include(Mycompany/Stores/IndexController.php) [<a href='function.include'>function.include</a>]: failed to open stream:...
Following benmarks first suggestion from the linked post above, I get an error:Fatal error: Uncaught exception 'Exception' with message 'Warning: include(Mycompany/Stores/IndexController.php) [<a href='function.include'>function.include</a>]: failed to open stream:...
但是遵循第二个建议,我得到了:
But following the second suggestion, I get:
["storepickup"] => array(2) {
[0] => string(14) "Mycompany_Stores"
[1] => string(21) "Magestore_Storepickup"
}
因此似乎有一个替代,但是我无法弄清楚为什么未调用indexAction()
或任何其他方法的原因.
So it appears that there is an override, but I cannot figure out why my indexAction()
or any other method is not getting called.
编辑:当我访问www.site.com/stores时,在我的config.xml
文件中定义自己的路线是可行的:
Defining my own route in my config.xml
file is working when I go to www.site.com/stores:
<stores>
<use>standard</use>
<args>
<module>Mycompany_Stores</module>
<frontName>stores</frontName>
</args>
</stores>
我仍然无法弄清楚为什么我的控制器没有覆盖扩展名.我已经能够覆盖同一模块中的块,而不仅仅是控制器.
I still cannot figure out why My controller is not overriding the extension though. I have been able to override blocks within this same module, just not the controller.
推荐答案
如果您还没有尝试过,我会在您的app/etc/modules/MyCompany_MyModule.xml
文件中放入一个依赖项标签,例如:
If you haven't already tried, I would put in a dependency tag into your app/etc/modules/MyCompany_MyModule.xml
file, something like:
...
<active>true</active>
<codePool>local</codePool>
<depends>
<Magestore_Storepickup/> <!-- load after Magestore_Storepickup -->
</depends>
...
这篇关于在自定义模块中覆盖Magento第三方控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!