I'm trying to determine on a plugin if the request comes from admin or for frontend.
I had to make a plugin for Magento\Framework\App\Config\ScopeConfigInterface, and in my plugin I need to detect the area code on my aroundGetValue function.
I'm trying this:
$om = \Magento\Framework\App\ObjectManager::getInstance();
$area = $om->get('Magento\Framework\App\State');
$areaCode= $area->getAreaCode();
But when I deploy my code I'm getting this error:
[Magento\Framework\Exception\LocalizedException]
Area code is not set
I don't know how to check at that level if the request comes from admin or for frontend.
Can anyone help me with this?
Best Answer
On your construct, put:
And try again