Magento 1.9:有没有一种方法可以在不重命名整个模块的情况下重命名路由?

时间:2017-12-27 07:49:05

标签: php magento magento-1.7 magento-1.9

我正在开发一个名为Namespace_Ticket的模块适合作为发票清单的项目。

但是,访问此模块的URL如下所示:

http://dev.local/index.php/tickets/index/index/ticket_id/9568/

我希望能够从网址中删除“门票”一词,并将其替换为“发票”。我希望我的网址看起来像这样:

http://dev.local/index.php/invoices/index/index/invoice_id/9568/

有没有办法可以在不重命名整个模块的情况下完成?

谢谢。

1 个答案:

答案 0 :(得分:2)

路由器名称在模块的etc/config.xml文件中定义,您将找到类似于下面的代码

<routers>
    <modulename> <!--or this may be ticket -->
        <use>standard</use>
        <args>
           <module>Namespace_Ticket</module>
           <frontName>tickets</frontName> <!-- You have to change this value to change the router -->
        </args>
    </modulename>
</routers>

需要为管理员和前端单独定义路由器,您可以在<frontend><admin>节点下找到。

更改路由器前端名称后,请确保在整个站点中使用网址的任何位置都必须更改路由器。