How to get a url parameter in Magento controller?

后端 未结 3 1642
不思量自难忘°
不思量自难忘° 2020-12-25 14:13

Is there a Magento function to get the value of \"id\" from this url:

http://example.com/path/action/id/123

I know I can split the url on \"/\" to get the va

3条回答
  •  不思量自难忘°
    2020-12-25 14:27

    If your url is the following structure: http://yoursiteurl.com/index.php/admin/sales_order_invoice/save/order_id/1795/key/b62f67bcaa908cdf54f0d4260d4fa847/

    then use:

    echo $this->getRequest()->getParam('order_id'); // output is 1795
    

    If you want to get All Url Value or Parameter value than use below code.

    var_dump($this->getRequest()->getParams());
    

    If your url is like this: http://magentoo.blogspot.com/magentooo/userId=21

    then use this to get the value of url

    echo $_GET['userId'];
    

    If you want more info about this click here.

提交回复
热议问题