In this post I am going to explain how to get module, controller, action and route name in Magento 2. 1. Using Dependency Injection Add below code snippet in Block class. protected $_request; public function __construct( \Magento\Framework\View\Element\Template\Context $context, \Magento\Framework\App\Request\Http $request, array $data = [] ) { $this->_request = $request; parent::__construct($context, $data); } public function getModuleName()…


Recent Comments