简体   繁体   English

Magento URL重写选项

[英]Magento URL rewrite option

I want to modify the Catalogsearch of magento. 我想修改magento的Catalogsearch。 So i followed this inchoo article - http://inchoo.net/ecommerce/magento/advanced-search-in-magento-and-how-to-use-it-in-your-own-way/ and i got it worked. 所以我遵循了这一inchoo文章- http://inchoo.net/ecommerce/magento/advanced-search-in-magento-and-how-to-use-it-in-your-own-way/我得到了它的工作。

So my url became - www.site.com/catalogsearch/custom/ 所以我的网址变成了-www.site.com/catalogsearch/custom/

But instead of this - want the last controller part(/custom/), its parameters should be seo friendly(like /style/Barbera/ instead of ?style=Barbera). 但是,除了这个-想要最后一个控制器部件(/ custom /),它的参数应该是seo友好的(例如/ style / Barbera /而不是?style = Barbera)。 So i want something like this. 所以我想要这样的东西。

www.site.com/catalogsearch/custom/style/Barbera/year/1980/ www.site.com/catalogsearch/custom/style/Barbera/year/1980/

and Controller needs to parse this parts 控制器需要解析这部分

style/Barbera/year/1980/ into 样式/巴贝拉/年/ 1980 /

style=Barbera year = 1980 and should quesy against adavced catalog models. style = Barbera year = 1980并且应该反对已建立的目录模型。

Please is anyone experienced with this custom url rewrite options to the controller with all its parameters. 请有经验的人使用此自定义url重写选项及其对控制器的所有参数。

Please help me. 请帮我。

Thanks in advance. 提前致谢。

I don't know if it is (easily) possible to do exactly what you have stated. 我不知道是否有可能(轻松地)完全按照您所说的去做。 If you change your desired url to be 如果您将所需的网址更改为

www.site.com/catalogsearch/custom/ index /style/Barbera/year/1980/ www.site.com/catalogsearch/custom/ 索引 / style / Barbera / year / 1980 /

then it is possible to achieve. 那么就有可能实现。 Notice the extra "index". 注意额外的“索引”。 To get this to work, you need to make sure that the function in your custom controller is indexAction(), of course. 为了使它起作用,您当然需要确保自定义控制器中的函数是indexAction()。 To parse the parameters in your controller you need to do something like this: 要解析控制器中的参数,您需要执行以下操作:

$style = $this->getRequest()->getParam('style');
$year = $this->getRequest()->getParam('year');
//OR if you aren't accessing in a controller you might need to do this...
$style = Mage::app()->getRequest()->getParam('style');
$year = Mage::app()->getRequest()->getParam('year');

To write out the url you will do something like this: 要写出URL,您将执行以下操作:

Mage::getUrl('catalogsearch/custom/index', array('style' => 'Barbera', 'year' => 1980)); 

But if you are dead set on NOT having the "index" in the url, then I am sure there is a way around it, just not sure how to do it. 但是,如果您死于在URL中没有“索引”,那我肯定有办法解决,只是不确定如何去做。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM