Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

$this->getRequest()->getParam() not working in category controller

I am working on retriving the manufacturer attribute from url

localhost/magento/index.php/test-pro.html?manufacturer/4

So i used $this->getRequest()->getParam('manufacturer')

I did not get any output.

But when i changed the url as localhost/magento/index.php/test-pro.html?manufacturer=4
(/ replaced by =), i get proper output.

But i need the url should be localhost/magento/index.php/test-pro.html?manufacturer/4

and want to fetch the product related to that manufacturer id 4.

Somebody help me.

like image 316
vinothavn Avatar asked May 13 '14 09:05

vinothavn


1 Answers

In your query string ?manufacturer=4 will give you the value for manufacturer i.e. 4, while manufacturer/4 will give you no value as its not being treated as query string.

Also the param will be and the param will be manufacturer/4 and not manufacturer.

To achieve what you require, you can do sometinhg like below.

$currentUrl = 'localhost/magento/index.php/test-pro.html?manufacturer/4';
$parts = parse_url($currentUrl);
$val =  explode('/',$parts['query']);
Mage::register('manufacturer',$val[1]);
$menuVal = Mage::registry('manufacturer');
echo $menuVal; //prints 4

This is a sample code by which you can get the query string value even if you use / instead of =.

like image 66
Slimshadddyyy Avatar answered Nov 07 '22 05:11

Slimshadddyyy