/**
  * {@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;
 }
示例#2
0
 /**
  * Get iterations count for step
  *
  * @return int
  */
 protected function getIterationsCount()
 {
     return count($this->helper->getDocumentList());
 }
示例#3
0
文件: Data.php 项目: okite11/frames21
 /**
  * @return array
  */
 protected function getDocumentList()
 {
     return $this->helper->getSelectData();
 }
 /**
  * @return array
  */
 public function getUpdateData()
 {
     $updateData = ['sales_flat_order_grid' => ['idKey' => 'entity_id', 'methods' => ['getSelectSalesOrderGrid']], 'sales_flat_invoice_grid' => ['idKey' => 'entity_id', 'methods' => ['getSelectSalesInvoiceGrid']], 'sales_flat_shipment_grid' => ['idKey' => 'entity_id', 'methods' => ['getSelectSalesShipmentGrid']], 'sales_flat_creditmemo_grid' => ['idKey' => 'entity_id', 'methods' => ['getSelectSalesCreditmemoGrid']], 'enterprise_sales_order_grid_archive' => ['idKey' => 'entity_id', 'methods' => ['getSelectSalesOrderGridArchive']], 'enterprise_sales_invoice_grid_archive' => ['idKey' => 'entity_id', 'methods' => ['getSelectSalesInvoiceGridArchive']], 'enterprise_sales_shipment_grid_archive' => ['idKey' => 'entity_id', 'methods' => ['getSelectSalesShipmentGridArchive']], 'enterprise_sales_creditmemo_grid_archive' => ['idKey' => 'entity_id', 'methods' => ['getSelectSalesCreditmemoGridArchive']]];
     return array_merge_recursive(parent::getUpdateData(), $updateData);
 }