Magento getURL找不到自定义模块的控制器

时间:2014-02-08 00:33:39

标签: magento controller geturl

我正在为销售订单网格添加新的批量操作,当我为我的操作添加网址时,Magento无法找到我的控制器。

config.xml中

<admin>
    <routers>
        <mymodule>
        <use>admin</use>
        <args>
            <module>Namespace_mymodule</module>
            <frontName>frontendname</frontName>
        </args>
        </mymodule>
    </routers>
</admin>

<global>
    <events>
        <adminhtml_block_html_before>
        <observers>
            <mymodule>
            <class>Namespace_mymodule_Model_Observer</class>
            <method>addActions</method>
            </mymodule>
        </observers>
        </adminhtml_block_html_before>
    </events>
</global>

observer.php

public function addActions($event)
{
    $block = $event->getBlock();
    if($block instanceof Mage_Adminhtml_Block_Sales_Order_Grid)
    {
        $block->getMassactionBlock()->addItem('cpsync', array(
            'label' => 'Push Orders to CounterPoint',
            'url' => Mage::helper("adminhtml")->getUrl("frontendname/adminhtml_index/push/")
        ));
    }
}

每当我尝试使用我的群发动作时,它会将我发送到带有网址

的404重定向页面

sitename.com/index.php/frontendname/adminhtml_index/push/key /

1 个答案:

答案 0 :(得分:0)

我认为你的config.xml错了。在上面的config.xml中,您没有提到模型,块或帮助器类。您刚刚宣布了模块和事件。这是您必须遵循的基本config.xml。尝试修改config.xml,如下所示。

    <?xml version="1.0"?>
<config>
    <modules>
        <Test_Helloworld>
            <version>0.1.0</version>
        </Test_Helloworld>
    </modules>
    <frontend>
        <routers>
            <helloworld>
                <use>standard</use>
                <args>
                    <module>Test_Helloworld</module>
                    <frontName>helloworld</frontName>
                </args>
            </helloworld>
        </routers>
        <layout>
            <updates>
                <helloworld>
                    <file>helloworld.xml</file>
                </helloworld>
            </updates>
        </layout>
    </frontend>
    <global>
        <blocks>
            <helloworld>
                <class>Test_Helloworld_Block</class>
            </helloworld>
        </blocks>
        <helpers>
            <helloworld>
                <class>Test_Helloworld_Helper</class>
            </helloworld>
        </helpers>
    </global>
</config>