$ this-> getRequest() - > getParam()在类别控制器中不起作用

vin*_*avn 6 magento magento-1.7 magento-1.8

我正在努力从url中恢复制造商属性

本地主机/ magento的/ index.php的/测试pro.html?制造商/ 4

所以我用过 $this->getRequest()->getParam('manufacturer')

我没有得到任何输出.

但是当我将url更改为localhost/magento/index.php/test-pro.html?manufacturer = 4
(/替换为=)时,我得到了正确的输出.

但我需要url应该是localhost/magento/index.php/test-pro.html?manufacturer/4

并希望获取与该制造商ID相关的产品4.

来人帮帮我.

Sli*_*yyy 3

在您的查询字符串中,?manufacturer=4将为您提供 ie 4 的值manufacturer,而制造商/4不会为您提供任何值,因为它不被视为查询字符串。

此外,参数将为制造商/4而不是制造商

为了实现您的要求,您可以执行如下操作。

$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
Run Code Online (Sandbox Code Playgroud)

/这是一个示例代码,即使您使用而不是 ,也可以通过它获取查询字符串值=