/**
  * {@inheritdoc}
  */
 public function perform()
 {
     $updateData = $this->helper->getUpdateData();
     $selectData = $this->helper->getSelectData();
     $sourceDocuments = $this->readerGroups->getGroup('source_documents');
     foreach ($sourceDocuments as $sourceDocName => $idKey) {
         if ($this->source->getRecordsCount($this->source->getDeltaLogName($sourceDocName)) == 0) {
             continue;
         }
         $items = $this->source->getChangedRecords($sourceDocName, $idKey, 0, true);
         if (empty($items)) {
             continue;
         }
         $this->logger->debug(sprintf('%s has changes', $sourceDocName));
         if (!$this->eolOnce) {
             $this->eolOnce = true;
             echo PHP_EOL;
         }
         $gridIdKey = $updateData[$sourceDocName]['idKey'];
         $page = 1;
         do {
             $ids = [];
             foreach ($items as $data) {
                 echo '.';
                 $ids[] = $data[$gridIdKey];
             }
             foreach ($updateData[$sourceDocName]['methods'] as $method) {
                 echo '.';
                 $destinationDocumentName = $selectData[$method]['destination'];
                 $select = call_user_func_array([$this->data, $method], [$selectData[$method]['columns'], $ids]);
                 $this->destination->getAdapter()->insertFromSelect($select, $this->destination->addDocumentPrefix($destinationDocumentName), [], \Magento\Framework\Db\Adapter\AdapterInterface::INSERT_ON_DUPLICATE);
             }
             $documentNameDelta = $this->source->getDeltaLogName($sourceDocName);
             $documentNameDelta = $this->source->addDocumentPrefix($documentNameDelta);
             $this->markRecordsProcessed($documentNameDelta, $idKey, $ids);
         } while (!empty($items = $this->source->getChangedRecords($sourceDocName, $idKey, $page++)));
     }
     return true;
 }
Exemple #2
0
 /**
  * @return array
  */
 protected function getDocumentList()
 {
     return $this->helper->getSelectData();
 }
 /**
  * @inheritdoc
  */
 public function getSelectData()
 {
     $selectedData = parent::getSelectData();
     $documentListArchive = ['getSelectSalesOrderGridArchive' => $this->getDocumentData('magento_sales_order_grid_archive'), 'getSelectSalesInvoiceGridArchive' => $this->getDocumentData('magento_sales_invoice_grid_archive'), 'getSelectSalesShipmentGridArchive' => $this->getDocumentData('magento_sales_shipment_grid_archive'), 'getSelectSalesCreditmemoGridArchive' => $this->getDocumentData('magento_sales_creditmemo_grid_archive')];
     return array_merge($selectedData, $documentListArchive);
 }