Bonjour,
Je dois créer des clients depuis un cron qui importe des données depuis une API externe, mais je rencontre des erreurs quand je veux sauvegarder les données. A noter que je n'ai pas de soucis pour importer les produits ( et product sale elements).
Je tente de créer mon customer à l'aide de la classe CustomerCreateOrUpdateEvent :
$customerCreation = new CustomerCreateOrUpdateEvent(
1, // Mr
'prenom',
'nom',
'54 rue test',
'',
'',
'0658454515',
'0654875935',
'67100',
'Strasbourg',
64, //France
'test@gmail.com',
'tebnbvnvbnvbst',
1, //français
false,
null,
null,
null,
'CUS000000000TEST1'
);
$this->getDispatcher()->dispatch(TheliaEvents::CUSTOMER_CREATEACCOUNT, $customerCreation);
L'élément customerCreation est bien existant, mais que je fais mon dispatch, je rencontre cette erreur :
PHP Fatal error: Uncaught Symfony\Component\Debug\Exception\FatalThrowableError: Fatal error: Call to a member function getSession() on null in /[...]/thelia/vendor/thelia/core/lib/Thelia/Core/Template/ParserContext.php:332
Stack trace:
#0 /[...]/thelia/vendor/thelia/core/lib/Thelia/Core/Template/ParserContext.php(276): Thelia\Core\Template\ParserContext->getSession()
#1 /[...]/thelia/vendor/thelia/core/lib/Thelia/Core/Template/ParserContext.php(59): Thelia\Core\Template\ParserContext->cleanOutdatedFormErrorInformation()
#2 /[...]/thelia/cache/dev/CoreDevDebugProjectContainer.php(4415): Thelia\Core\Template\ParserContext->__construct(Object(Symfony\Component\HttpFoundation\RequestStack), Object(Thelia\Core\Form\TheliaFormFactory), Object(Thelia\Core\Form\TheliaFormValidator))
#3 /[...]/thelia/vendor/symfony/dependency-injection/Container.php(316): CoreDevDebugProjectContainer->getThelia_Parser_ContextService()
#4 /[...]/theli in /[...]/vendor/thelia/core/lib/Thelia/Core/Template/ParserContext.php on line 332
Le script est exécuté dans une commande Thelia, ce qui peut expliquer qu'il n'y a pas de "session". Du coup, faut t'il passer par une autre méthode ?
Cordialement