- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ciao, sto sviluppando un sito usando la versione 2.3 di magento 2, sto sviluppando una procedura utilizzando codice php, ho importato le librerie di magento con il segunte codice:
try {
//require __DIR__ . '/app/bootstrap.php';
require '../../app/bootstrap.php';
}catch(\Exception $e) {
echo $e->getMessage() . PHP_EOL;
exit(1);
}
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);
/** @var \Magento\Framework\App\Http $app */
//$app = $bootstrap->createApplication('Magento\Framework\App\Http');
//$bootstrap->run($app);
// YOUR CODE HERE
$objectManager = $bootstrap->getObjectManager();
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$appState = $objectManager->get("Magento\Framework\App\State");
$appState->setAreaCode("it");
Quando tento d'importare mi da il seguente errore:
Fatal error: Uncaught Magento\Framework\Exception\LocalizedException: Area code "it" does not exist
Non riesco a capire il perchè, se qualcuno mi può dare una mano a risolvere il problema.
Grazie in Anticipo
Solved! Go to Solution.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ciao,
Devi impostare il codice sotto a $appState->setAreaCode("it");
$this->state->setAreaCode(\Magento\Framework\App\Area::AREA_FRONTEND);
-
Se la mia risposta è utile, si prega di accettare come soluzione e dare Kudos
--
If my answer is useful, please Accept as Solution & give Kudos
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Problema di settaggio dell'Area Code
Ciao @gtwolf ,
Si prega di sostituire il codice sottostante e provarlo
$appState = $objectManager->get("Magento\Framework\App\State");
sostituirlo con
$appState = $objectManager->create("Magento\Framework\App\State");
-
Se la mia risposta è utile, si prega di accettare come soluzione e dare Kudos
If my answer is useful, please Accept as Solution & give Kudos
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Problema di settaggio dell'Area Code
Ciao, anche facendo così purtroppo il problema persiste
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ciao,
Devi impostare il codice sotto a $appState->setAreaCode("it");
$this->state->setAreaCode(\Magento\Framework\App\Area::AREA_FRONTEND);
-
Se la mia risposta è utile, si prega di accettare come soluzione e dare Kudos
--
If my answer is useful, please Accept as Solution & give Kudos