Skip to main content

XtCore

This article contains solutions and answers for common problems that occur while installing Xtento_XtCore for Magento 2.

Area code not set: Area code must be set before starting a session.

If you try to install the Xtento_XtCore module and get the following error message while running "setup:upgrade":

`Module 'Xtento_XtCore':
Installing data...

[Magento\Framework\Exception\SessionException]
Area code not set: Area code must be set before starting a session.

[Magento\Framework\Exception\LocalizedException]
Area code is not set`

This is an error we see for about 1 of 500 installations. Please do the following:

Open the file "app/code/Xtento/XtCore/Setup/InstallData.php" (or if installed via composer: "vendor/xtento/module-xtcore/Setup/InstallData.php") and look for:

public function __construct(\Magento\Framework\App\Config\ValueFactory $configValueFactory) \{ $this->configValueFactory = $configValueFactory; \}

Replace this with: public function __construct(\Magento\Framework\App\Config\ValueFactory $configValueFactory, \Magento\Framework\App\State $appState) \{ $appState->setAreaCode('adminhtml'); $this->configValueFactory = $configValueFactory; \}

Save the file. Then run "setup:upgrade" again. This must be done one-time only and you can then revert the file InstallData.php to the original version again.