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

11

Try this

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

Where

 $your_query = array('new_query' => 123)

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.