Ejemplo n.º 1
0
 /**
  * @param string  $key
  * @param Address $entity
  */
 public function fillEntityData($key, $entity)
 {
     $countryRepo = $this->templateManager->getEntityRepository('Oro\\Bundle\\AddressBundle\\Entity\\Country');
     $regionRepo = $this->templateManager->getEntityRepository('Oro\\Bundle\\AddressBundle\\Entity\\Region');
     switch ($key) {
         case 'Jerry Coleman':
             $entity->setCity('Rochester')->setStreet('1215 Caldwell Road')->setPostalCode('14608')->setFirstName('Jerry')->setLastName('Coleman')->setRegion($regionRepo->getEntity('NY'))->setCountry($countryRepo->getEntity('US'));
             return;
         case 'John Smith':
             $entity->setCity('New York')->setStreet('4677 Pallet Street')->setPostalCode('10011')->setFirstName('John')->setLastName('Smith')->setRegion($regionRepo->getEntity('NY'))->setCountry($countryRepo->getEntity('US'));
             return;
         case 'John Doo':
             $entity->setCity('New York')->setStreet('52 Jarvisville Road')->setPostalCode('11590')->setFirstName('John')->setLastName('Doo')->setRegion($regionRepo->getEntity('NY'))->setCountry($countryRepo->getEntity('US'));
             return;
     }
     parent::fillEntityData($key, $entity);
 }
Ejemplo n.º 2
0
 /**
  * @param Organization $organization
  * @param array        $data
  * @param Channel      $channel
  *
  * @return B2bCustomer
  */
 protected function createCustomer(Organization $organization, $data, Channel $channel = null)
 {
     $address = new Address();
     $customer = new B2bCustomer();
     $customer->setName($data['Company']);
     $customer->setOwner($this->getRandomUserReference());
     $customer->setAccount($this->getAccount());
     $customer->setOrganization($organization);
     $address->setCity($data['City']);
     $address->setStreet($data['StreetAddress']);
     $address->setPostalCode($data['ZipCode']);
     $address->setFirstName($data['GivenName']);
     $address->setLastName($data['Surname']);
     $address->setCountry($this->getCountryReference($data['Country']));
     $address->setRegion($this->getRegionReference($data['Country'], $data['State']));
     $customer->setShippingAddress($address);
     $customer->setBillingAddress(clone $address);
     if ($channel) {
         $customer->setDataChannel($channel);
     }
     return $customer;
 }
Ejemplo n.º 3
0
 /**
  * @param $region
  * @param $country
  *
  * @return Address
  */
 protected function createAddress($region, $country)
 {
     $address = new Address();
     $address->setRegion($region);
     $address->setCountry($country);
     $address->setCity('City');
     $address->setStreet('street');
     $address->setPostalCode(123456);
     $address->setFirstName('John');
     $address->setLastName('Doe');
     $address->setOrganization($this->organization);
     $this->em->persist($address);
     return $address;
 }
Ejemplo n.º 4
0
 /**
  * @param  array $data
  * @param User   $user
  *
  * @return Lead
  */
 protected function createLead(array $data, $user)
 {
     $lead = new Lead();
     /** @var LeadStatus $defaultStatus */
     $defaultStatus = $this->em->find('OroCRMSalesBundle:LeadStatus', 'new');
     $lead->setStatus($defaultStatus);
     $lead->setName($data['Company']);
     $lead->setFirstName($data['GivenName']);
     $lead->setLastName($data['Surname']);
     $lead->setEmail($data['EmailAddress']);
     $lead->setPhoneNumber($data['TelephoneNumber']);
     $lead->setCompanyName($data['Company']);
     $lead->setOwner($user);
     $lead->setDataChannel($this->channel);
     /** @var Address $address */
     $address = new Address();
     $address->setLabel('Primary Address');
     $address->setCity($data['City']);
     $address->setStreet($data['StreetAddress']);
     $address->setPostalCode($data['ZipCode']);
     $address->setFirstName($data['GivenName']);
     $address->setLastName($data['Surname']);
     $isoCode = $data['Country'];
     $country = array_filter($this->countries, function (Country $a) use($isoCode) {
         return $a->getIso2Code() == $isoCode;
     });
     $country = array_values($country);
     /** @var Country $country */
     $country = $country[0];
     $idRegion = $data['State'];
     /** @var Collection $regions */
     $regions = $country->getRegions();
     $region = $regions->filter(function (Region $a) use($idRegion) {
         return $a->getCode() == $idRegion;
     });
     $address->setCountry($country);
     if (!$region->isEmpty()) {
         $address->setRegion($region->first());
     }
     $lead->setAddress($address);
     $countSources = count($this->sources) - 1;
     $source = $this->sources[mt_rand(0, $countSources)];
     $lead->setSource($source);
     return $lead;
 }