Magento 控制器未加载?

Magento 控制器未加载?,magento,Magento,我试图编辑从这里生成的报告,example.com/index.php/admin/sales\u order/index/。我需要在右边的下拉列表中添加一个新报告 <global> <blocks> <daves_ordermodule> <!-- this is the class group and must be lowercase--> <class&

我试图编辑从这里生成的报告,
example.com/index.php/admin/sales\u order/index/
。我需要在右边的下拉列表中添加一个新报告

    <global>
        <blocks>
            <daves_ordermodule> <!-- this is the class group  and must be lowercase-->
                <class>Daves_OrderModule_Block</class> <!-- this is how you access it -->
            </daves_ordermodule>
        </blocks>
        <helpers>
            <daves_ordermodule>
                <class>Daves_OrderModule_Helper</class> <!-- Mage::helper('squaresphere_module/<helper>'); -->
            </daves_ordermodule>
        </helpers>
        <models>
            <daves_ordermodule>
                <class>Daves_OrderModule_Model</class> <!-- Mage::getModel('squaresphere_module/<model>'); -->
            </daves_ordermodule>
        </models>

    </global>

    <!-- How to get to the module from the browser -->
    <admin>
        <routers>
            <daves_ordermodule> <!-- My unique class group -->
                <use>admin</use> <!-- which router class? -->
                <args>
                    <module>Daves_OrderModule</module> <!-- assumes /controllers -->
                    <frontName>daves_ordermodule</frontName> <!-- what is on the url -->
                </args>
            </daves_ordermodule>
        </routers>
    </admin>

</config>
我通过url跟踪这个页面到它的控制器,并转储了这个类。
app/code/core/Mage/Adminhtml/controllers/Sales/OrderController.php indexAction()
并得到了这个类
Ext4mage\u Html2pdf\u Sales\u OrderController
,所以我知道它被一个模块覆盖了。在本例中,使用Ext4mage Html2pdf模块

    <global>
        <blocks>
            <daves_ordermodule> <!-- this is the class group  and must be lowercase-->
                <class>Daves_OrderModule_Block</class> <!-- this is how you access it -->
            </daves_ordermodule>
        </blocks>
        <helpers>
            <daves_ordermodule>
                <class>Daves_OrderModule_Helper</class> <!-- Mage::helper('squaresphere_module/<helper>'); -->
            </daves_ordermodule>
        </helpers>
        <models>
            <daves_ordermodule>
                <class>Daves_OrderModule_Model</class> <!-- Mage::getModel('squaresphere_module/<model>'); -->
            </daves_ordermodule>
        </models>

    </global>

    <!-- How to get to the module from the browser -->
    <admin>
        <routers>
            <daves_ordermodule> <!-- My unique class group -->
                <use>admin</use> <!-- which router class? -->
                <args>
                    <module>Daves_OrderModule</module> <!-- assumes /controllers -->
                    <frontName>daves_ordermodule</frontName> <!-- what is on the url -->
                </args>
            </daves_ordermodule>
        </routers>
    </admin>

</config>
此控制器仅使用覆盖pdf方法

require_once BP.'/app/code/core/Mage/Adminhtml/controllers/Sales/OrderController.php';
class Ext4mage_Html2pdf_Sales_OrderController extends Mage_Adminhtml_Sales_OrderController{
//etc }
    <global>
        <blocks>
            <daves_ordermodule> <!-- this is the class group  and must be lowercase-->
                <class>Daves_OrderModule_Block</class> <!-- this is how you access it -->
            </daves_ordermodule>
        </blocks>
        <helpers>
            <daves_ordermodule>
                <class>Daves_OrderModule_Helper</class> <!-- Mage::helper('squaresphere_module/<helper>'); -->
            </daves_ordermodule>
        </helpers>
        <models>
            <daves_ordermodule>
                <class>Daves_OrderModule_Model</class> <!-- Mage::getModel('squaresphere_module/<model>'); -->
            </daves_ordermodule>
        </models>

    </global>

    <!-- How to get to the module from the browser -->
    <admin>
        <routers>
            <daves_ordermodule> <!-- My unique class group -->
                <use>admin</use> <!-- which router class? -->
                <args>
                    <module>Daves_OrderModule</module> <!-- assumes /controllers -->
                    <frontName>daves_ordermodule</frontName> <!-- what is on the url -->
                </args>
            </daves_ordermodule>
        </routers>
    </admin>

</config>
所以我在本地创建了我的新模块,希望在社区中覆盖它。
app/code/local/Daves/OrderModule/controllers/Sales/OrderController.php
并放置在以下位置

require_once 'Mage'.DS.'Adminhtml'.DS.'controllers'.DS.'Sales'.DS.'OrderController.php';
require_once BP.'/app/code/community/Ext4mage/Html2pdf/controllers/Sales/OrderController.php';

class Daves_OrderModule_Sales_OrderController extends Ext4mage_Html2pdf_Sales_OrderController{

    public function indexAction(){

        die();

        return parent::indexAction();
    }

}
    <global>
        <blocks>
            <daves_ordermodule> <!-- this is the class group  and must be lowercase-->
                <class>Daves_OrderModule_Block</class> <!-- this is how you access it -->
            </daves_ordermodule>
        </blocks>
        <helpers>
            <daves_ordermodule>
                <class>Daves_OrderModule_Helper</class> <!-- Mage::helper('squaresphere_module/<helper>'); -->
            </daves_ordermodule>
        </helpers>
        <models>
            <daves_ordermodule>
                <class>Daves_OrderModule_Model</class> <!-- Mage::getModel('squaresphere_module/<model>'); -->
            </daves_ordermodule>
        </models>

    </global>

    <!-- How to get to the module from the browser -->
    <admin>
        <routers>
            <daves_ordermodule> <!-- My unique class group -->
                <use>admin</use> <!-- which router class? -->
                <args>
                    <module>Daves_OrderModule</module> <!-- assumes /controllers -->
                    <frontName>daves_ordermodule</frontName> <!-- what is on the url -->
                </args>
            </daves_ordermodule>
        </routers>
    </admin>

</config>
我期望的功能是,在管理中重新加载销售/订单页面时,我会得到一个空白页面,而我不会。这意味着我的控制器没有被加载

    <global>
        <blocks>
            <daves_ordermodule> <!-- this is the class group  and must be lowercase-->
                <class>Daves_OrderModule_Block</class> <!-- this is how you access it -->
            </daves_ordermodule>
        </blocks>
        <helpers>
            <daves_ordermodule>
                <class>Daves_OrderModule_Helper</class> <!-- Mage::helper('squaresphere_module/<helper>'); -->
            </daves_ordermodule>
        </helpers>
        <models>
            <daves_ordermodule>
                <class>Daves_OrderModule_Model</class> <!-- Mage::getModel('squaresphere_module/<model>'); -->
            </daves_ordermodule>
        </models>

    </global>

    <!-- How to get to the module from the browser -->
    <admin>
        <routers>
            <daves_ordermodule> <!-- My unique class group -->
                <use>admin</use> <!-- which router class? -->
                <args>
                    <module>Daves_OrderModule</module> <!-- assumes /controllers -->
                    <frontName>daves_ordermodule</frontName> <!-- what is on the url -->
                </args>
            </daves_ordermodule>
        </routers>
    </admin>

</config>
我的IDE显示类正在被扩展,并将
die()
放入Ext4mage\u Html2pdf控制器中的
indexAction()
方法中,正如预期的那样工作。它只是因为某种原因失去了我的控制器

    <global>
        <blocks>
            <daves_ordermodule> <!-- this is the class group  and must be lowercase-->
                <class>Daves_OrderModule_Block</class> <!-- this is how you access it -->
            </daves_ordermodule>
        </blocks>
        <helpers>
            <daves_ordermodule>
                <class>Daves_OrderModule_Helper</class> <!-- Mage::helper('squaresphere_module/<helper>'); -->
            </daves_ordermodule>
        </helpers>
        <models>
            <daves_ordermodule>
                <class>Daves_OrderModule_Model</class> <!-- Mage::getModel('squaresphere_module/<model>'); -->
            </daves_ordermodule>
        </models>

    </global>

    <!-- How to get to the module from the browser -->
    <admin>
        <routers>
            <daves_ordermodule> <!-- My unique class group -->
                <use>admin</use> <!-- which router class? -->
                <args>
                    <module>Daves_OrderModule</module> <!-- assumes /controllers -->
                    <frontName>daves_ordermodule</frontName> <!-- what is on the url -->
                </args>
            </daves_ordermodule>
        </routers>
    </admin>

</config>
尝试使用
example.com/admin/daves\u ordermodule/sales\u order/index
在浏览器中直接点击控制器也会抛出404

    <global>
        <blocks>
            <daves_ordermodule> <!-- this is the class group  and must be lowercase-->
                <class>Daves_OrderModule_Block</class> <!-- this is how you access it -->
            </daves_ordermodule>
        </blocks>
        <helpers>
            <daves_ordermodule>
                <class>Daves_OrderModule_Helper</class> <!-- Mage::helper('squaresphere_module/<helper>'); -->
            </daves_ordermodule>
        </helpers>
        <models>
            <daves_ordermodule>
                <class>Daves_OrderModule_Model</class> <!-- Mage::getModel('squaresphere_module/<model>'); -->
            </daves_ordermodule>
        </models>

    </global>

    <!-- How to get to the module from the browser -->
    <admin>
        <routers>
            <daves_ordermodule> <!-- My unique class group -->
                <use>admin</use> <!-- which router class? -->
                <args>
                    <module>Daves_OrderModule</module> <!-- assumes /controllers -->
                    <frontName>daves_ordermodule</frontName> <!-- what is on the url -->
                </args>
            </daves_ordermodule>
        </routers>
    </admin>

</config>
我应该尝试覆盖这些块吗

    <global>
        <blocks>
            <daves_ordermodule> <!-- this is the class group  and must be lowercase-->
                <class>Daves_OrderModule_Block</class> <!-- this is how you access it -->
            </daves_ordermodule>
        </blocks>
        <helpers>
            <daves_ordermodule>
                <class>Daves_OrderModule_Helper</class> <!-- Mage::helper('squaresphere_module/<helper>'); -->
            </daves_ordermodule>
        </helpers>
        <models>
            <daves_ordermodule>
                <class>Daves_OrderModule_Model</class> <!-- Mage::getModel('squaresphere_module/<model>'); -->
            </daves_ordermodule>
        </models>

    </global>

    <!-- How to get to the module from the browser -->
    <admin>
        <routers>
            <daves_ordermodule> <!-- My unique class group -->
                <use>admin</use> <!-- which router class? -->
                <args>
                    <module>Daves_OrderModule</module> <!-- assumes /controllers -->
                    <frontName>daves_ordermodule</frontName> <!-- what is on the url -->
                </args>
            </daves_ordermodule>
        </routers>
    </admin>

</config>
我没有在我的配置中创建任何时髦的
更新句柄,主要是因为我不确定我是否需要它们,或者它们会去哪里。据我所知,Magento在可怕的xml使用中借鉴了Zend,我将在这里粘贴我的配置

    <global>
        <blocks>
            <daves_ordermodule> <!-- this is the class group  and must be lowercase-->
                <class>Daves_OrderModule_Block</class> <!-- this is how you access it -->
            </daves_ordermodule>
        </blocks>
        <helpers>
            <daves_ordermodule>
                <class>Daves_OrderModule_Helper</class> <!-- Mage::helper('squaresphere_module/<helper>'); -->
            </daves_ordermodule>
        </helpers>
        <models>
            <daves_ordermodule>
                <class>Daves_OrderModule_Model</class> <!-- Mage::getModel('squaresphere_module/<model>'); -->
            </daves_ordermodule>
        </models>

    </global>

    <!-- How to get to the module from the browser -->
    <admin>
        <routers>
            <daves_ordermodule> <!-- My unique class group -->
                <use>admin</use> <!-- which router class? -->
                <args>
                    <module>Daves_OrderModule</module> <!-- assumes /controllers -->
                    <frontName>daves_ordermodule</frontName> <!-- what is on the url -->
                </args>
            </daves_ordermodule>
        </routers>
    </admin>

</config>

app/etc/modules/Daves\u OrderModule.xml

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <Daves_OrderModule>
            <active>true</active>
            <codePool>local</codePool>
            <depends> <!-- same as in the /app/etc/Mage_All.xml -->
                <Mage_Reports/>
                <Mage_Adminhtml/>
                <Ext4mage_Html2pdf/>
            </depends>
        </Daves_OrderModule>
    </modules>
</config>
    <global>
        <blocks>
            <daves_ordermodule> <!-- this is the class group  and must be lowercase-->
                <class>Daves_OrderModule_Block</class> <!-- this is how you access it -->
            </daves_ordermodule>
        </blocks>
        <helpers>
            <daves_ordermodule>
                <class>Daves_OrderModule_Helper</class> <!-- Mage::helper('squaresphere_module/<helper>'); -->
            </daves_ordermodule>
        </helpers>
        <models>
            <daves_ordermodule>
                <class>Daves_OrderModule_Model</class> <!-- Mage::getModel('squaresphere_module/<model>'); -->
            </daves_ordermodule>
        </models>

    </global>

    <!-- How to get to the module from the browser -->
    <admin>
        <routers>
            <daves_ordermodule> <!-- My unique class group -->
                <use>admin</use> <!-- which router class? -->
                <args>
                    <module>Daves_OrderModule</module> <!-- assumes /controllers -->
                    <frontName>daves_ordermodule</frontName> <!-- what is on the url -->
                </args>
            </daves_ordermodule>
        </routers>
    </admin>

</config>

app/code/community/Ext4mage/Html2pdf/etc/config.xml

    <global>
        <blocks>
            <daves_ordermodule> <!-- this is the class group  and must be lowercase-->
                <class>Daves_OrderModule_Block</class> <!-- this is how you access it -->
            </daves_ordermodule>
        </blocks>
        <helpers>
            <daves_ordermodule>
                <class>Daves_OrderModule_Helper</class> <!-- Mage::helper('squaresphere_module/<helper>'); -->
            </daves_ordermodule>
        </helpers>
        <models>
            <daves_ordermodule>
                <class>Daves_OrderModule_Model</class> <!-- Mage::getModel('squaresphere_module/<model>'); -->
            </daves_ordermodule>
        </models>

    </global>

    <!-- How to get to the module from the browser -->
    <admin>
        <routers>
            <daves_ordermodule> <!-- My unique class group -->
                <use>admin</use> <!-- which router class? -->
                <args>
                    <module>Daves_OrderModule</module> <!-- assumes /controllers -->
                    <frontName>daves_ordermodule</frontName> <!-- what is on the url -->
                </args>
            </daves_ordermodule>
        </routers>
    </admin>

</config>
<admin>
    <routers>
        <html2pdf>
            <use>admin</use>
            <args>
                <module>Ext4mage_Html2pdf</module>
                <frontName>html2pdf</frontName>
            </args>
        </html2pdf>
        <emailattachments>
            <args>
                <modules>
                    <Ext4mage_Html2pdf before="Fooman_EmailAttachments">Ext4mage_Html2pdf</Ext4mage_Html2pdf>
                </modules>
            </args>
        </emailattachments>
        <adminhtml>
            <args>
                <modules>
                    <Ext4mage_Html2pdf before="Mage_Adminhtml">Ext4mage_Html2pdf</Ext4mage_Html2pdf>
                </modules>
            </args>
        </adminhtml>
    </routers>
</admin>

管理
Ext4mage_Html2pdf
html2pdf
Ext4mage_Html2pdf
Ext4mage_Html2pdf

假设您没有前端控制器,请按如下方式调整配置:

    <global>
        <blocks>
            <daves_ordermodule> <!-- this is the class group  and must be lowercase-->
                <class>Daves_OrderModule_Block</class> <!-- this is how you access it -->
            </daves_ordermodule>
        </blocks>
        <helpers>
            <daves_ordermodule>
                <class>Daves_OrderModule_Helper</class> <!-- Mage::helper('squaresphere_module/<helper>'); -->
            </daves_ordermodule>
        </helpers>
        <models>
            <daves_ordermodule>
                <class>Daves_OrderModule_Model</class> <!-- Mage::getModel('squaresphere_module/<model>'); -->
            </daves_ordermodule>
        </models>

    </global>

    <!-- How to get to the module from the browser -->
    <admin>
        <routers>
            <daves_ordermodule> <!-- My unique class group -->
                <use>admin</use> <!-- which router class? -->
                <args>
                    <module>Daves_OrderModule</module> <!-- assumes /controllers -->
                    <frontName>daves_ordermodule</frontName> <!-- what is on the url -->
                </args>
            </daves_ordermodule>
        </routers>
    </admin>

</config>
<!-- How to get to the module from the browser -->
<admin>
    <routers>
        <adminhtml> <!-- My unique class group -->
            <args>
                <modules>
                    <Daves_Om before="Ext4mage_Html2pdf">Daves_OrderModule</Daves_Om>
                </modules>
            </args>
        </adminhtml>
    </routers>
</admin>

Daves_排序模块

这样做的目的是在Mage_Adminhtml模块的frontname下添加另一个控制器目录。
中的值基本上映射到文本节点+“controllers”,因此
app/code/(配置的代码池)/Daves/OrderModule/controllers/
-然后应用典型的路由匹配。

您所做的远远超出了您的需要:-)。。。请从
Ext4mage\u Html2pdf
模块中添加相关的
配置,您将从我或其他人那里得到答案。嘿@benmarks我现在已经包含了来自etc/config for Html2pdfHi的路由器节点,下面阅读的文章是控制器覆盖的最佳解决方案,谢谢!等我回来的时候我会试一试的。我已经把它搁置了几天,让它成熟;P
    <global>
        <blocks>
            <daves_ordermodule> <!-- this is the class group  and must be lowercase-->
                <class>Daves_OrderModule_Block</class> <!-- this is how you access it -->
            </daves_ordermodule>
        </blocks>
        <helpers>
            <daves_ordermodule>
                <class>Daves_OrderModule_Helper</class> <!-- Mage::helper('squaresphere_module/<helper>'); -->
            </daves_ordermodule>
        </helpers>
        <models>
            <daves_ordermodule>
                <class>Daves_OrderModule_Model</class> <!-- Mage::getModel('squaresphere_module/<model>'); -->
            </daves_ordermodule>
        </models>

    </global>

    <!-- How to get to the module from the browser -->
    <admin>
        <routers>
            <daves_ordermodule> <!-- My unique class group -->
                <use>admin</use> <!-- which router class? -->
                <args>
                    <module>Daves_OrderModule</module> <!-- assumes /controllers -->
                    <frontName>daves_ordermodule</frontName> <!-- what is on the url -->
                </args>
            </daves_ordermodule>
        </routers>
    </admin>

</config>