【问题标题】:Magento getURL not finding controller of custom moduleMagento getURL 找不到自定义模块的控制器
【发布时间】:2014-02-08 00:33:38
【问题描述】:

我正在为销售订单网格添加一个新的批量操作,当我为我的操作输入 URL 时,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/")
        ));
    }
}

每当我尝试使用集体行动时,它都会将我发送到带有 url 的 404 重定向页面

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

【问题讨论】:

  • 您可能对我的免费/开源“Better 404”模块感兴趣。它将 Magento 的标准 404 页面替换为 404,其中包含有关 Magento 为何认为它无法找到您的页面的诊断信息。 alanstorm.com/magento-404-debug

标签: magento controller geturl


【解决方案1】:

我认为你的 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> 

【讨论】:

  • 您好,我认为没有必要包括在内,但我在就像你的一样。仍然没有任何效果。
猜你喜欢
  • 2016-06-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-05-06
  • 1970-01-01
  • 1970-01-01
  • 2013-01-17
相关资源
最近更新 更多