I have my basic product listing, which redirects to the product view page like this: <a href="<?php echo $_product->getProductUrl() ?>"> Now I want to add my own variable to the url but I have no idea how to achieve that.

I've tried just simply adding ?value=value but it returns errors


You cant add a POST parameter to an URL. What you can do is add a GET parameter to the url like this:

<a href="<?php echo $_product->getProductUrl() ?>/name_of_param/value">Link</a>

and retrieve it afterwards with

  • To slightly expand on the above, if you need to send POST data you will need to do something like submit a form or make an AJAX request. – Jonathan Hussey Nov 11 '14 at 14:23
  • @JonathanHussey i'm making an AJAX request. but if im working in list.phtml and want to post the data to list.phtml i'm not sure what url to refer to – user3164891 Nov 11 '14 at 14:32
  • If the request you are making results in the list.phtml template rendering then you can pull the POST param with Mage::app()->getRequest()->getPost() to pull POST data sent with the request. – Jonathan Hussey Nov 11 '14 at 14:47

You can directly append value to function like...

 <a href="<?php echo $_product->getProductUrl().'/param1/value1/param2/value2' ?>">Product Link</a>

Fetch value from controller like this,


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.