Example #1
0
 /**
  * If customer exists then add relation to it,
  * do nothing otherwise
  *
  * @param Order $entity
  */
 protected function processCustomer(Order $entity)
 {
     // customer could be array if comes new order or object if comes from DB
     $customerId = is_object($entity->getCustomer()) ? $entity->getCustomer()->getOriginId() : $entity->getCustomer()['originId'];
     $criteria = ['originId' => $customerId, 'channel' => $entity->getChannel()];
     /** @var Customer|null $customer */
     $customer = $this->getEntityByCriteria($criteria, MagentoConnectorInterface::CUSTOMER_TYPE);
     if ($customer instanceof Customer) {
         // now customer orders subtotal calculation support only one currency.
         // also we do not take into account order refunds due to magento does not bring subtotal data
         // customer currency needs on customer's grid to format lifetime value.
         $customer->setCurrency($entity->getCurrency());
     }
     $entity->setCustomer($customer);
 }
Example #2
0
 /**
  * @param Order $order
  * @param Customer $customer
  */
 protected function processCustomer(Order $order, Customer $customer = null)
 {
     if (!$customer || !$customer->getId()) {
         $customer = $this->databaseHelper->findOneBy('OroCRM\\Bundle\\MagentoBundle\\Entity\\Customer', ['email' => $order->getCustomerEmail(), 'channel' => $order->getChannel()]);
     }
     if ($customer instanceof Customer) {
         // now customer orders subtotal calculation support only one currency.
         // also we do not take into account order refunds due to magento does not bring subtotal data
         // customer currency needs on customer's grid to format lifetime value.
         $customer->setCurrency($order->getCurrency());
     }
     $order->setCustomer($customer);
     if ($order->getCart()) {
         $order->getCart()->setCustomer($customer);
     }
 }