diff --git a/src/Creator/OrderCreator.php b/src/Creator/OrderCreator.php index 4b5266d..8d1016d 100644 --- a/src/Creator/OrderCreator.php +++ b/src/Creator/OrderCreator.php @@ -4,7 +4,9 @@ use Address; use Cart; +use Context; use Customer; +use Employee; use Faker\Generator as Faker; use Order; use OrderState; @@ -25,6 +27,12 @@ public function __construct( $this->faker = $faker; $this->cartCreator = $cartCreator; $this->customerCreator = $customerCreator; + + // Because we could be in CLI mode, there might be no employee in context, so we must set it manually + $context = Context::getContext(); + if (!isset($context->employee) || !isset($context->employee->id)) { + $context->employee = new Employee(1); + } } public function generate(int $number, int $idShopGroup, int $idShop, array $productIds): void