/** * {@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); } }
/** * @param $region * @param $country * * @return MagentoAddress */ protected function createMagentoAddress($region, $country) { $address = new MagentoAddress(); $address->setRegion($region); $address->setCountry($country); $address->setCity('City'); $address->setStreet('street'); $address->setPostalCode(123456); $address->setFirstName('John'); $address->setLastName('Doe'); $address->setLabel('label'); $address->setPrimary(true); $address->setOrganization('oro'); $address->setOriginId(1); $address->setOrganization($this->organization); $this->em->persist($address); return $address; }