예제 #1
0
 /**
  * Set customer parameters from customer entity.
  *
  * @param Siwapp\CustomerBundle\Entity\Customer $customer
  */
 public function setFromCustomer(Customer $customer)
 {
     if (empty($this->customer_name) && $customer->getName()) {
         $this->customer_name = $customer->getName();
     }
     if (empty($this->customer_email) && $customer->getEmail()) {
         $this->customer_email = $customer->getEmail();
     }
     if (empty($this->customer_identification) && $customer->getIdentification()) {
         $this->customer_identification = $customer->getIdentification();
     }
     if (empty($this->contact_person) && $customer->getContactPerson()) {
         $this->contact_person = $customer->getContactPerson();
     }
     if (empty($this->invoicing_address) && $customer->getInvoicingAddress()) {
         $this->invoicing_address = $customer->getInvoicingAddress();
     }
     if (empty($this->shipping_address) && $customer->getShippingAddress()) {
         $this->shipping_address = $customer->getShippingAddress();
     }
 }
예제 #2
0
 protected function importCustomers(\PDO $dbh, EntityManager $em)
 {
     $count = 0;
     $sth = $dbh->prepare('SELECT * FROM customer');
     $sth->execute();
     foreach ($sth->fetchAll(\PDO::FETCH_ASSOC) as $row) {
         if (empty($row['name'])) {
             // Do not import records with empty name.
             continue;
         }
         $customer = new Customer();
         $customer->setName($row['name']);
         if ($row['identification'] && $row['identification'] !== 'Client Legal Id') {
             $customer->setIdentification($row['identification']);
         }
         $email = $row['email'];
         // In previous version email was optional.
         if (!$email) {
             $email = strtolower(str_replace(' ', '-', $name)) . '@upgradefrom04.fixme';
         }
         $customer->setEmail($email);
         $customer->setContactPerson($row['contact_person']);
         $customer->setInvoicingAddress($row['invoicing_address']);
         $customer->setShippingAddress($row['shipping_address']);
         $em->persist($customer);
         $count++;
     }
     return $count;
 }