Is there a way I can check that If a user on a category page,or an individual product page in Magento 2?
Any help would be greatly appreciated!
categorymagento2
Is there a way I can check that If a user on a category page,or an individual product page in Magento 2?
Any help would be greatly appreciated!
Best Answer
You can try below code it might help you.
Inject an instance of
\Magento\Framework\App\Request\Http
in your class constructor.If you are in a controller you don't need to do it. You can already access it like this
$request = $this->getRequest()
Then you can check if is category or product like this: