How to check if the current area is frontend or backend?
How to check if the current area is frontend or backend?

How to check if the current area is frontend or backend?

Use Magento\Framework\App\State class to get the area code of the current page. I will show you how you can get the current area by object manager and with dependency injection. With ObjectManager: $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $state = $objectManager->get('Magento\Framework\App\State'); echo $state->getAreaCode(); With Dependency Injection: protected $_state; public function __construct ( \Magento\Framework\App\State $state ) { $this->_state =…

Continue Reading How to check if the current area is frontend or backend?