Skip to main content

Magento 2 – How to identify current page in phtml file?

Magento 2 – How to identify current page in phtml file?

 

$currentFullAction = $block->getRequest()->getFullActionName();

$catpages= array('catalog_category_view','catalog_product_view');

if(in_array($currentFullAction, $catpages)){
    //Catalog page
}