如何重定向到Magento中的操作?

如何重定向到Magento中的操作?,magento,router,Magento,Router,嗨 我正在尝试为我的自定义模块创建路由器 我想通过url/hotsale访问索引控制器的hotsale操作。因此,我在模块的config.xml中创建了以下路由器xml <hotsale> <use>standard</use> <args> <module>Moon_Products</module> <frontName>hotsale</frontName> </args&g

我正在尝试为我的自定义模块创建路由器

我想通过url/hotsale访问索引控制器的hotsale操作。因此,我在模块的config.xml中创建了以下路由器xml

<hotsale>
 <use>standard</use>
 <args>
  <module>Moon_Products</module>
  <frontName>hotsale</frontName>
 </args>
</hotsale>

默认前端/商店路由的工作方式如下

http://example.com/front-name/controller-name/action-name
那么,当你去

http://example.com/hostsale
你真的是说

http://example.com/hostsale/index/index
前端名称的概念有点抽象,但实际上是将URL绑定到特定模块

因此,如果有一个名为
hotsaleAction
的方法的
IndexController.php
,并且您想要执行此方法,请使用表单中的URL

http://example.com/hotsale/index/hotsale 

//是否仍然可以在xml中直接将/hotitem路由到hotitemAction?Re:重写默认的Magento路由,以便/hotitem直接路由到hotitemAction。也许吧,但这并不容易(在我看来,也不值得)。我从未尝试过,但我的方法是将“”更改为自定义值,将自定义路由器添加到配置中,为该路由器创建路由器类,然后重写match方法。(我不能100%肯定这会让你逍遥法外)。我会让你的索引做一些类似于[return$this->hotsaleAction]的事情。更快、更容易,而且不会混淆下一个开发人员。//是的,我接受了你的建议。
http://example.com/hotsale/index/hotsale