Exemple #1
0
 /**
  * {@inheritdoc}
  */
 public function process($newEntity)
 {
     $oid = $newEntity->getOriginId();
     /** @var Cart $newEntity */
     /** @var Cart $existingEntity */
     $existingEntity = $this->getEntityByCriteria(['originId' => $oid, 'channel' => $newEntity->getChannel()], $newEntity);
     if ($existingEntity) {
         $this->strategyHelper->importEntity($existingEntity, $newEntity, ['id', 'store', 'status', 'cartItems', 'customer', 'relatedCalls', 'relatedEmails', 'shippingAddress', 'billingAddress', 'workflowItem', 'workflowStep', 'owner']);
         $this->removeErrorMessage($existingEntity);
     } else {
         $hasContactInfo = $newEntity->getBillingAddress() && $newEntity->getBillingAddress()->getPhone() || $newEntity->getEmail();
         if (!$newEntity->getItemsCount()) {
             $this->context->incrementErrorEntriesCount();
             $this->logger->debug(sprintf('Cart ID: %d was skipped because it does not have items', $oid));
             return false;
         } elseif (!$hasContactInfo) {
             $this->context->incrementErrorEntriesCount();
             $this->logger->debug(sprintf('Cart ID: %d was skipped because lack of contact info', $oid));
             return false;
         }
         $existingEntity = $newEntity;
         // populate owner only for newly created entities
         $this->defaultOwnerHelper->populateChannelOwner($newEntity, $newEntity->getChannel());
     }
     $this->updateCartStatus($existingEntity, $newEntity->getStatus());
     if (!$existingEntity->getStore() || !$existingEntity->getStore()->getId()) {
         $existingEntity->setStore($this->storeStrategy->process($newEntity->getStore()));
     }
     $newEntity->getCustomer()->setChannel($newEntity->getChannel());
     $this->updateCustomer($existingEntity, $newEntity->getCustomer())->updateAddresses($existingEntity, $newEntity)->updateCartItems($existingEntity, $newEntity->getCartItems());
     return $this->validateAndUpdateContext($existingEntity);
 }
Exemple #2
0
 /**
  * @param Order $entity
  */
 protected function processStore(Order $entity)
 {
     $entity->setStore($this->storeStrategy->process($entity->getStore()));
 }