Magento URL rewrite option
I want to modify the Catalogsearch of magento. 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.
So my url became - www.site.com/catalogsearch/custom/
But instead o开发者_JAVA百科f this - want the last controller part(/custom/), its parameters should be seo friendly(like /style/Barbera/ instead of ?style=Barbera). So i want something like this.
www.site.com/catalogsearch/custom/style/Barbera/year/1980/
and Controller needs to parse this parts
style/Barbera/year/1980/ into
style=Barbera year = 1980 and should quesy against adavced catalog models.
Please is anyone experienced with this custom url rewrite options to the controller with all its parameters.
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/
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. 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:
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.
精彩评论