示例#1
0
 /**
  * @param Cart $entity
  *
  * {@inheritdoc}
  */
 protected function afterProcessEntity($entity)
 {
     if ($this->existingEntity->getStatus()->getName() === CartStatus::STATUS_OPEN) {
         $this->updateRemovedCartItems($entity);
     }
     if (!$this->hasContactInfo($entity)) {
         return null;
     }
     $this->updateCustomer($entity)->updateAddresses($entity)->updateCartItems($entity)->updateCartStatus($entity);
     $this->existingEntity = null;
     $this->existingCartItems = null;
     return parent::afterProcessEntity($entity);
 }
示例#2
0
 /**
  * @param Cart $entity
  *
  * {@inheritdoc}
  */
 protected function afterProcessEntity($entity)
 {
     if ($this->existingEntity->getStatus()->getName() === CartStatus::STATUS_OPEN) {
         $this->updateRemovedCartItems($entity);
     }
     if (!$this->hasContactInfo($entity)) {
         return null;
     }
     $this->updateCustomer($entity)->updateAddresses($entity)->updateCartItems($entity)->updateCartStatus($entity);
     $now = new \DateTime('now', new \DateTimeZone('UTC'));
     if (!$entity->getImportedAt()) {
         $entity->setImportedAt($now);
     }
     $entity->setSyncedAt($now);
     $this->existingEntity = null;
     $this->existingCartItems = null;
     return parent::afterProcessEntity($entity);
 }
示例#3
0
 /**
  * {@inheritdoc}
  */
 protected function findExistingEntity($entity, array $searchContext = [])
 {
     if ($entity instanceof Customer) {
         $website = $this->databaseHelper->findOneBy('OroCRM\\Bundle\\MagentoBundle\\Entity\\Website', ['originId' => $entity->getWebsite()->getOriginId(), 'channel' => $entity->getChannel()]);
         if ($website) {
             $searchContext['website'] = $website;
         }
         /** @var Customer $existingEntity */
         $existingEntity = parent::findExistingEntity($entity, $searchContext);
         if (!$existingEntity) {
             $existingEntity = $this->databaseHelper->findOneBy('OroCRM\\Bundle\\MagentoBundle\\Entity\\Customer', ['email' => $entity->getEmail(), 'channel' => $entity->getChannel(), 'website' => $website]);
             if ($existingEntity && $existingEntity->getId()) {
                 if ($existingEntity->isGuest()) {
                     $existingEntity->setGuest(false);
                     $existingEntity->setIsActive(true);
                 }
                 if ($entity->getOriginId()) {
                     $existingEntity->setOriginId($entity->getOriginId());
                 }
             }
         }
     } else {
         /** @var Customer $existingEntity */
         $existingEntity = parent::findExistingEntity($entity, $searchContext);
     }
     return $existingEntity;
 }
 /**
  * @param NewsletterSubscriber $entity
  * @return NewsletterSubscriber
  */
 protected function afterProcessEntity($entity)
 {
     $this->processChangeStatusAt($entity);
     return parent::afterProcessEntity($entity);
 }
示例#5
0
 /**
  * @param Customer $entity
  *
  * {@inheritdoc}
  */
 protected function afterProcessEntity($entity)
 {
     $this->processChangeAttributes($entity);
     return parent::afterProcessEntity($entity);
 }
示例#6
0
 /**
  * BC layer to find existing collection items by old identity filed values
  *
  * {@inheritdoc}
  */
 protected function findExistingEntity($entity, array $searchContext = [])
 {
     $existingEntity = parent::findExistingEntity($entity, $searchContext);
     if (!$existingEntity && $entity instanceof OrderAddress) {
         $propertyAccessor = PropertyAccess::createPropertyAccessor();
         /** @var OrderAddress $existingEntity */
         $existingEntity = $this->existingEntity->getAddresses()->filter(function (OrderAddress $address) use($entity, $propertyAccessor) {
             $isMatched = true;
             $fieldsToMatch = ['street', 'city', 'postalCode', 'country', 'region'];
             foreach ($fieldsToMatch as $fieldToMatch) {
                 $addressValue = $propertyAccessor->getValue($address, $fieldToMatch);
                 $entityValue = $propertyAccessor->getValue($entity, $fieldToMatch);
                 $isMatched = $isMatched && $addressValue === $entityValue;
             }
             return $isMatched;
         })->first();
         if ($existingEntity && $entity->getOriginId()) {
             $existingEntity->setOriginId($entity->getOriginId());
         }
     }
     return $existingEntity;
 }
示例#7
0
 /**
  * BC layer to find existing collection items by old identity filed values
  *
  * {@inheritdoc}
  */
 protected function findExistingEntity($entity, array $searchContext = [])
 {
     $existingEntity = parent::findExistingEntity($entity, $searchContext);
     if (!$existingEntity && $entity instanceof OrderAddress) {
         /** @var OrderAddress $existingEntity */
         $existingEntity = $this->existingEntity->getAddresses()->filter(function (OrderAddress $address) use($entity) {
             $isMatched = true;
             $fieldsToMatch = ['street', 'city', 'postalCode', 'country', 'region'];
             foreach ($fieldsToMatch as $fieldToMatch) {
                 $addressValue = $this->getPropertyAccessor()->getValue($address, $fieldToMatch);
                 $entityValue = $this->getPropertyAccessor()->getValue($entity, $fieldToMatch);
                 $isMatched = $isMatched && $addressValue === $entityValue;
             }
             return $isMatched;
         })->first();
         if ($existingEntity && $entity->getOriginId()) {
             $existingEntity->setOriginId($entity->getOriginId());
         }
     }
     if ($entity instanceof OrderItem && is_null($entity->getName())) {
         //name can't be null, so to avoid import job failing empty string is used
         $entity->setName('');
     }
     return $existingEntity;
 }