/**
  * @param EntityManager $manager
  * {@inheritdoc}
  */
 public function load(ObjectManager $manager)
 {
     $locator = $this->container->get('file_locator');
     $filePath = $locator->locate('@OroB2BOrderBundle/Migrations/Data/Demo/ORM/data/orders.csv');
     if (is_array($filePath)) {
         $filePath = current($filePath);
     }
     $handler = fopen($filePath, 'r');
     $headers = fgetcsv($handler, 1000, ',');
     /** @var EntityRepository $userRepository */
     $userRepository = $manager->getRepository('OroUserBundle:User');
     /** @var User $user */
     $user = $userRepository->findOneBy([]);
     $accountUser = $this->getAccountUser($manager);
     while (($data = fgetcsv($handler, 1000, ',')) !== false) {
         $row = array_combine($headers, array_values($data));
         $order = new Order();
         $billingAddress = ['label' => $row['billingAddressLabel'], 'country' => $row['billingAddressCountry'], 'city' => $row['billingAddressCity'], 'region' => $row['billingAddressRegion'], 'street' => $row['billingAddressStreet'], 'postalCode' => $row['billingAddressPostalCode']];
         $shippingAddress = ['label' => $row['shippingAddressLabel'], 'country' => $row['shippingAddressCountry'], 'city' => $row['shippingAddressCity'], 'region' => $row['shippingAddressRegion'], 'street' => $row['shippingAddressStreet'], 'postalCode' => $row['shippingAddressPostalCode']];
         $order->setOwner($user)->setAccount($accountUser->getAccount())->setIdentifier($row['identifier'])->setAccountUser($accountUser)->setOrganization($user->getOrganization())->setBillingAddress($this->createOrderAddress($manager, $billingAddress))->setShippingAddress($this->createOrderAddress($manager, $shippingAddress))->setPaymentTerm($this->getPaymentTerm($manager, $row['paymentTerm']))->setPriceList($this->getPriceList($manager, $row['priceListName']))->setShipUntil(new \DateTime())->setCurrency($row['currency'])->setPoNumber($row['poNumber'])->setSubtotal($row['subtotal']);
         if (!empty($row['customerNotes'])) {
             $order->setCustomerNotes($row['customerNotes']);
         }
         $manager->persist($order);
     }
     fclose($handler);
     $manager->flush();
 }