/** * @param $firstName * @param $lastname */ protected function createCustomer($firstName, $lastname) { $customer = new Customer(); $customer->setChannel($this->getReference('integration')); $customer->setDataChannel($this->getReference('default_channel')); $customer->setFirstName($firstName); $customer->setLastName($lastname); $customer->setEmail(strtolower($firstName . '_' . $lastname . '@example.com')); $customer->setIsActive(true); $customer->setWebsite($this->getReference('website')); $customer->setStore($this->getReference('store')); $customer->setAccount($this->getReference('account')); $customer->setGender(Gender::MALE); $customer->setGroup($this->getReference('customer_group')); $customer->setCreatedAt(new \DateTime('now')); $customer->setUpdatedAt(new \DateTime('now')); $customer->setOwner($this->user); $customer->setOrganization($this->organization); $this->em->persist($customer); }
/** * {@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']); $customer->setCreatedAt(new \DateTime()); $customer->setUpdatedAt($customer->getCreatedAt()); 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 $oid * @param Account $account * @param MagentoAddress $address * * @return Customer */ protected function createCustomer($oid, Account $account, MagentoAddress $address) { $customer = new Customer(); $customer->setChannel($this->integration); $customer->setDataChannel($this->channel); $customer->setFirstName('John'); $customer->setLastName('Doe'); $customer->setEmail('*****@*****.**'); $customer->setOriginId($oid); $customer->setIsActive(true); $customer->setWebsite($this->website); $customer->setStore($this->store); $customer->setAccount($account); $customer->setGender(Gender::MALE); $customer->setGroup($this->customerGroup); $customer->setCreatedAt(new \DateTime('now')); $customer->setUpdatedAt(new \DateTime('now')); $customer->addAddress($address); $customer->setOwner($this->getUser()); $customer->setOrganization($this->organization); $this->em->persist($customer); return $customer; }
/** * @param $oid * @param Account $account * @param MagentoAddress $address * * @return Customer */ protected function createCustomer($oid, Account $account, MagentoAddress $address) { $customer = new Customer(); $customer->setChannel($this->integration); $customer->setDataChannel($this->channel); $customer->setFirstName('John'); $customer->setLastName('Doe'); $customer->setEmail('*****@*****.**'); $customer->setOriginId($oid); $customer->setIsActive(true); $customer->setWebsite($this->website); $customer->setStore($this->store); $customer->setAccount($account); $customer->setGender(Gender::MALE); $customer->setGroup($this->customerGroup); // TODO: DateTimeZones should be removed in BAP-8710. Tests should be passed for: // - OroCRM\Bundle\MagentoBundle\Tests\Functional\Controller\Api\Rest\CustomerControllerTest // - OroCRM\Bundle\MagentoBundle\Tests\Functional\Controller\Api\Rest\MagentoCustomerControllerTest $customer->setCreatedAt(new \DateTime('now', new \DateTimezone('UTC'))); $customer->setUpdatedAt(new \DateTime('now', new \DateTimezone('UTC'))); $customer->addAddress($address); $customer->setOwner($this->getUser()); $customer->setOrganization($this->organization); $this->em->persist($customer); return $customer; }
/** * @param Customer $object * @param array $data * @param mixed $format * @param array $context */ protected function setObjectFieldsValues(Customer $object, array $data, $format = null, array $context = array()) { if (!empty($data['birthday'])) { /** @var \DateTime $birthday */ $birthday = $this->denormalizeObject($data, 'birthday', 'DateTime', $format, array_merge($context, ['type' => 'date'])); $object->setBirthday($birthday); unset($data['birthday']); } if (!empty($data['created_at'])) { /** @var \DateTime $createdAt */ $createdAt = $this->denormalizeObject($data, 'created_at', 'DateTime', $format, $context); $object->setCreatedAt($createdAt); } if (!empty($data['updated_at'])) { /** @var \DateTime $updatedAt */ $updatedAt = $this->denormalizeObject($data, 'updated_at', 'DateTime', $format, $context); $object->setUpdatedAt($updatedAt); } $this->setContact($object, $data, $format, $context); $this->setWebsite($object, $data, $format, $context); $this->setStore($object, $data, $format, $context); $this->setGroup($object, $data, $format, $context); }