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:


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



Try this

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


 $your_query = array('new_query' => 123)
  • what is inside $your_query ? Nov 16 '17 at 8:54
  • 1
    It's works for me Nov 16 '17 at 8:59
  • Which file need to edit to add query param? Oct 4 '19 at 13:44
  • how can i get or echo the current url with the query parameter in phtml file?
    – Ali Raza
    Sep 17 '21 at 13:49

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.