/** * init app state (add adminhtml configs as well) */ private function initAppState() { $appState = $this->getMagentoObject(State::class); $configLoader = $this->getMagentoObject(ConfigLoader::class); $registry = $this->getMagentoObject(Registry::class); try { $appState->getAreaCode(); } catch (\Exception $e) { $appState->setAreaCode('adminhtml'); $this->objectManager->configure($configLoader->load('adminhtml')); $registry->register('isSecureArea', true); } }