예제 #1
0
 /**
  * {@inheritdoc}
  *
  * Prepare items for PersistentBatchWriter, filters for duplicates and takes only latest versions
  */
 public function write(array $items)
 {
     $uniqueItems = [];
     $uniqueKeys = [];
     foreach ($items as $item) {
         if ($item instanceof Customer || $item instanceof Cart) {
             $this->handleIdentifier($uniqueItems, $item, $item->getOriginId());
         } elseif ($item instanceof Order) {
             $this->handleIdentifier($uniqueItems, $item, $item->getIncrementId());
         } elseif ($item instanceof NewsletterSubscriber) {
             $identifier = $item->getCustomer() ? $item->getCustomer()->getId() : 0;
             if ($identifier !== 0 && in_array($identifier, $uniqueKeys)) {
                 $this->logSkipped($item->getOriginId());
             } else {
                 $uniqueKeys[] = $identifier;
                 $uniqueItems[] = $item;
             }
         } else {
             $uniqueItems[] = $item;
         }
     }
     $this->writer->write($uniqueItems);
     // force entity cache clear if clear is skipped
     $this->databaseHelper->onClear();
 }
예제 #2
0
 /**
  * {@inheritdoc}
  *
  * Prepare items for PersistentBatchWriter, filters for duplicates and takes only latest versions
  */
 public function write(array $items)
 {
     $uniqueItems = [];
     foreach ($items as $item) {
         if ($item instanceof Customer || $item instanceof Cart) {
             $identifier = $item->getOriginId();
             if (array_key_exists($identifier, $uniqueItems)) {
                 $this->logSkipped($identifier);
             }
             if ($item instanceof Customer) {
                 $item->setIsSynced(true);
             }
             $uniqueItems[$identifier] = $item;
         } elseif ($item instanceof Order) {
             $identifier = $item->getIncrementId();
             if (array_key_exists($identifier, $uniqueItems)) {
                 $this->logSkipped($item->getIncrementId());
             }
             $uniqueItems[$identifier] = $item;
         } else {
             $uniqueItems[] = $item;
         }
     }
     $this->writer->write($uniqueItems);
     // force entity cache clear if clear is skipped
     $this->databaseHelper->onClear();
 }
예제 #3
0
 /**
  * @param array $processedItems
  *
  * @return null
  */
 protected function write($processedItems)
 {
     try {
         $this->writer->write($processedItems);
     } catch (InvalidItemException $e) {
         $this->handleStepExecutionWarning($this->stepExecution, $this->writer, $e);
     }
 }
예제 #4
0
 /**
  * @param array                                     $processedItems
  * @param StepExecutionWarningHandlerInterface|null $warningHandler
  *
  * @return null
  */
 protected function write($processedItems, StepExecutionWarningHandlerInterface $warningHandler = null)
 {
     try {
         $this->writer->write($processedItems);
     } catch (InvalidItemException $e) {
         $this->handleStepExecutionWarning($this->writer, $e, $warningHandler);
     }
 }