0

Is there a way to check that we are on search result page in Magento 2?

Any help would be greatly appreciated!

7
  • 2
    if you are checking for just testing you can try this ` $this->getRequest()->getFullActionName();` if you are at catalogsearch_result_index it means you are at search result page – Real Magento Man Jul 27 '19 at 12:56
  • Thanks buddy, its working for me. – Purushotam Sharma Jul 27 '19 at 13:04
  • welcome Happy Coding :) – Real Magento Man Jul 27 '19 at 13:11
  • Waqar Ali, please post this as answer – Amit Bera Jul 27 '19 at 14:27
  • @AmitBera i have Posted Answer you can check now – Real Magento Man Jul 28 '19 at 9:38
4

if you are checking for just testing you can try this

echo $this->getRequest()->getFullActionName(); 

if you are at

catalogsearch_result_index

it means you are at search result page

1

In .phtml try with below code :

print_r($this->getRequest()->getFullActionName());

if you get return like : catalogsearch_result_index

That is you are at search result page.

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.