Пример #1
0
 /**
  * @param string $documentName
  * @param string $idKey
  * @return void
  */
 protected function processChangedRecords($documentName, $idKey)
 {
     $destinationName = $this->mapReader->getDocumentMap($documentName, MapInterface::TYPE_SOURCE);
     $items = $this->source->getChangedRecords($documentName, $idKey);
     $sourceDocument = $this->source->getDocument($documentName);
     $destDocument = $this->destination->getDocument($destinationName);
     $recordTransformer = $this->getRecordTransformer($sourceDocument, $destDocument);
     $eavDocumentName = $this->helper->getDestEavDocument();
     $eavDocumentResource = $this->destination->getDocument($eavDocumentName);
     do {
         $destinationRecords = $destDocument->getRecords();
         $destEavCollection = $eavDocumentResource->getRecords();
         $ids = [];
         foreach ($items as $data) {
             echo '.';
             $ids[] = $data[$idKey];
             $this->transformData($data, $sourceDocument, $destDocument, $recordTransformer, $destinationRecords);
             $this->data->migrateAdditionalOrderData($data, $sourceDocument, $destEavCollection);
         }
         $this->destination->updateChangedRecords($destinationName, $destinationRecords);
         $this->destination->updateChangedRecords($eavDocumentName, $destEavCollection);
         $this->markRecordsProcessed($this->source->getDeltaLogName($documentName), $idKey, $ids);
     } while (!empty($items = $this->source->getChangedRecords($documentName, $idKey)));
 }
Пример #2
0
 /**
  * Entry point. Run migration of SalesOrder structure.
  * @return bool
  */
 public function perform()
 {
     $this->progress->start($this->getIterationsCount(), LogManager::LOG_LEVEL_INFO);
     $sourceDocuments = array_keys($this->helper->getDocumentList());
     foreach ($sourceDocuments as $sourceDocName) {
         $sourceDocument = $this->source->getDocument($sourceDocName);
         $destinationDocumentName = $this->map->getDocumentMap($sourceDocName, MapInterface::TYPE_SOURCE);
         if (!$destinationDocumentName) {
             continue;
         }
         $destDocument = $this->destination->getDocument($destinationDocumentName);
         $this->destination->clearDocument($destinationDocumentName);
         $eavDocumentName = $this->helper->getDestEavDocument();
         $eavDocumentResource = $this->destination->getDocument($eavDocumentName);
         /** @var \Migration\RecordTransformer $recordTransformer */
         $recordTransformer = $this->recordTransformerFactory->create(['sourceDocument' => $sourceDocument, 'destDocument' => $destDocument, 'mapReader' => $this->map]);
         $recordTransformer->init();
         $pageNumber = 0;
         $this->logger->debug('migrating', ['table' => $sourceDocName]);
         $this->progress->start($this->source->getRecordsCount($sourceDocName), LogManager::LOG_LEVEL_DEBUG);
         while (!empty($bulk = $this->source->getRecords($sourceDocName, $pageNumber))) {
             $pageNumber++;
             $destinationCollection = $destDocument->getRecords();
             $destEavCollection = $eavDocumentResource->getRecords();
             foreach ($bulk as $recordData) {
                 $this->progress->advance(LogManager::LOG_LEVEL_INFO);
                 $this->progress->advance(LogManager::LOG_LEVEL_DEBUG);
                 /** @var Record $sourceRecord */
                 $sourceRecord = $this->recordFactory->create(['document' => $sourceDocument, 'data' => $recordData]);
                 /** @var Record $destRecord */
                 $destRecord = $this->recordFactory->create(['document' => $destDocument]);
                 $recordTransformer->transform($sourceRecord, $destRecord);
                 $destinationCollection->addRecord($destRecord);
                 $this->migrateAdditionalOrderData($recordData, $sourceDocument, $destEavCollection);
             }
             $this->destination->saveRecords($destinationDocumentName, $destinationCollection);
             $this->destination->saveRecords($eavDocumentName, $destEavCollection);
             $this->progress->finish(LogManager::LOG_LEVEL_DEBUG);
         }
     }
     $this->progress->finish(LogManager::LOG_LEVEL_INFO);
     return true;
 }
Пример #3
0
 /**
  * Get iterations count for step
  *
  * @return int
  */
 protected function getIterationsCount()
 {
     $migrationDocuments = $this->helper->getDocumentList();
     $documents = [$this->helper->getDestEavDocument(), array_keys($migrationDocuments), array_values($migrationDocuments)];
     return count($documents);
 }
 /**
  * Load EAV data before migration
  * @return void
  */
 public function init()
 {
     $this->initDestAttributes($this->helper->getDestEavDocument());
 }
 /**
  * @return void
  */
 public function testGetDestEavDocument()
 {
     $destEavDocument = 'eav_entity_int';
     $this->assertEquals($destEavDocument, $this->helper->getDestEavDocument());
 }