4

I want to add query parameter to my current url, I'm getting current url in my phtml like this:

$current_url = $this->getUrl('*/*/*', ['_current' => true, '_use_rewrite' => true]);

I want to add query parameter to my url so it will look like this:

https://currenturl.com?new_query=123

And when the current url already has another query parameter, it will look like this:

https://currenturl.com?old_query=22&new_query=123

12

Try this

$current_url = $this->getUrl('*/*/*', array('_current' => true,'_use_rewrite' => true, '_query' => $your_query));

Where

 $your_query = array('new_query' => 123)
  • what is inside $your_query ? – Shell Suite Nov 16 '17 at 8:54
  • 1
    It's works for me – Vaibhav Ahalpara Nov 16 '17 at 8:59
  • Which file need to edit to add query param? – Shoaib Saleem Oct 4 at 13:44

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.