5

我在 Magento 管理面板中的模块具有类似http://example.com/index.php/mymodule/的 URL ...并包含带有订单的自定义网格。当他单击网格行时,我想将用户重定向到标准的“订单视图”页面。

public function getRowUrl($row)
{
    if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
        return $this->getUrl('sales_order/view', array('order_id' => $row->getId()));
    }
    return false;
}

但是这个 URL 指向http://example.com/index.php/sales_order/view/ ... 而不是http://example.com/index.php/ admin /sales_order/view/... 有什么建议吗?

UPD。配置.xml

<admin>
    <routers>
        <mymodule>
            <use>admin</use>
            <args>
                <module>Foo_Mymodule</module>
                <frontName>mymodule</frontName>
            </args>
        </mymodule>
    </routers>
</admin>
4

1 回答 1

7

很简单,您需要替换sales_order/view*/sales_order/view. 该*方法使用管理员中的当前路由器adminhtml

编辑
要更详细地解释,请将其放入您的配置中,

<admin>
    <routers>
        <adminhtml>
            <args>
                <modules>
                    <mymodule after="Mage_Adminhtml">Foo_Mymodule_Adminhtml</mymodule>
                </modules>
            </args>
        </adminhtml>
    </routers>
</admin>

Now the value */mymodule/index will generate an URL http://example.com/index.php/admin/mymodule/index which in turn will load the file Foo/Mymodule/controllers/Adminhtml/MymoduleController.php and try to find the method Foo_Mymodule_Adminhtml_MymoduleController::indexAction(). If the method exists it is run, otherwise the admin router takes over and shows a 404 or redirects to the dashboard.

于 2011-09-05T10:12:09.537 回答