/** * {@inheritdoc} */ public function run() { $this->logger->log('Installing orders:'); foreach ($this->fixtures as $file) { $fileName = $this->fixtureHelper->getPath($file); $csvReader = $this->csvReaderFactory->create(['fileName' => $fileName, 'mode' => 'r']); foreach ($csvReader as $row) { $orderData = $this->converter->convertRow($row); $this->orderProcessor->createOrder($orderData); $this->logger->logInline('.'); } } }
/** * {@inheritdoc} */ public function run() { $this->logger->log('Installing orders:'); foreach ($this->fixtures as $file) { $fileName = $this->fixtureHelper->getPath($file); $csvReader = $this->csvReaderFactory->create(['fileName' => $fileName, 'mode' => 'r']); $isFirst = true; foreach ($csvReader as $row) { if ($isFirst) { $customer = $this->customerRepository->get($row['customer_email']); if (!$customer->getId()) { continue; } /** @var \Magento\Sales\Model\Resource\Collection $orderCollection */ $orderCollection = $this->orderCollectionFactory->create(); $orderCollection->addFilter('customer_id', $customer->getId()); if ($orderCollection->count() > 0) { break; } } $isFirst = false; $orderData = $this->converter->convertRow($row); $this->orderProcessor->createOrder($orderData); $this->logger->logInline('.'); } } }