Magento 2: AREA

Установить\задать текущую Area
(Получить текущую Area можно аналогично, изменив метод set на get).
/** * @var \Magento\Framework\App\State */ protected $_appState; try { if (version_compare($version, '2.2.0', '>=')) { $this->_appState->setAreaCode(\Magento\Framework\App\Area::AREA_ADMINHTML); } else { $this->_appState->setAreaCode('admin'); } //area is alredy set } catch (\Exception $e) { $this->_appState->getAreaCode(); }