How to get Current page controller action in magento2:
Some times we may want to get which is current page in mageno2 website. Based on controller action we suppose to come to know which page is rendering.
Ex: catalog_product_view controller action mean it is PDP product detail page. Similarly using below script we come to know which page we are in magento2 website ect: Home page , List page, Cart page, CMS page
<?php
try{
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$request = $objectManager->get(‘Magento\Framework\App\Action\Context’)->getRequest();
$currentPageXML = $request->getFullActionName();
echo $currentPageXML; //catalog_product_view is product detail page controller action
}catch(Exception $e){}
?>