Every time I type something something in the search bar, I get redirected to the following url:


Is there a way to get the complete url through a php statement?

I tried this already:


but I only got this as result: https://XXXXXX.com/catalogsearch/result/ without the parameter ?q=typed_text_on_search_bar

Thanks for your inputs

  • can you share website URL?
    – kunj
    Jun 8 '18 at 8:27
  • Well, this is an staging environment which is protected from the outside; I guess I do not have permissions to share it; Jun 8 '18 at 9:22

You can use code from Magento Term block https://github.com/magento/magento2/blob/2.2-develop/app/code/Magento/Search/Block/Term.php#L123


This code snippet worked finally for me:

$query = "?product_list_limit=all";
$q = $this->getRequest()->getParam('q');
$query .= "&q=$q";

<a class="limiter" href="<?= $query ?>"><?php /* @escapeNotVerified */ echo __('View all') ?></a>

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.