How to get a url parameter in Magento controller? -
is there magento function value of "id" url:
http://example.com/path/action/id/123
i know can split url on "/" value, i'd prefer single function.
this doesn't work:
$id = $this->getrequest()->getparam('id'); it works if use http://example.com/path/action?id=123
magento's default routing algorithm uses three part urls.
http://example.com/front-name/controller-name/action-method so when call
http://example.com/path/action/id/123 the word path front name, action controller name, , id action method. after these 3 methods, can use getparam grab key/value pair
http://example.com/path/action/id/foo/123 //in controller var_dump($this->getrequest()->getparam('foo')); you may use getparams method grab array of parameters
$this->getrequest()->getparams()
Comments
Post a Comment