示例#1
0
 /**
  * {@inheritdoc}
  */
 public function load(ObjectManager $manager)
 {
     $addressTypeRepo = $manager->getRepository('OroAddressBundle:AddressType');
     foreach (self::$data as $item) {
         $customer = new Customer();
         $customer->setEmail($item['email']);
         $customer->setFirstName($item['firstName']);
         $customer->setLastName($item['lastName']);
         foreach ($item['addresses'] as $addressData) {
             $address = new Address();
             $address->setPostalCode($addressData['postalCode']);
             $address->addType($addressTypeRepo->findOneBy(['name' => $addressData['type']]));
             $customer->addAddress($address);
             $manager->persist($address);
         }
         $manager->persist($customer);
         $manager->flush();
         $this->setReference($item['reference'], $customer);
     }
 }