0

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

https://XXXXXX.com/catalogsearch/result/?q=typed_text_on_search_bar

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

I tried this already:

https://stackoverflow.com/questions/33955256/get-the-current-page-url-in-magento-2-0

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; – Julian Murillo Jun 8 '18 at 9:22
0

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

0

This code snippet worked finally for me:

<?php
$query = "?product_list_limit=all";
$q = $this->getRequest()->getParam('q');
if($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.