/**
  * @return void
  */
 public function setUp()
 {
     $this->progress = $this->getMock('\\Migration\\App\\ProgressBar\\LogLevelProcessor', ['start', 'finish', 'advance'], [], '', false);
     $this->source = $this->getMock('Migration\\ResourceModel\\Source', ['getDocument', 'getDocumentList', 'getRecords', 'getRecordsCount', 'getAdapter', 'addDocumentPrefix', 'getPageSize'], [], '', false);
     $this->destination = $this->getMock('Migration\\ResourceModel\\Destination', ['getDocument', 'getDocumentList', 'saveRecords', 'clearDocument'], [], '', false);
     $this->recordFactory = $this->getMock('Migration\\ResourceModel\\RecordFactory', ['create'], [], '', false);
     $this->recordTransformerFactory = $this->getMock('Migration\\RecordTransformerFactory', ['create'], [], '', false);
     $this->map = $this->getMockBuilder('Migration\\Reader\\Map')->disableOriginalConstructor()->setMethods(['getDocumentMap', 'init', 'getDocumentList', 'getDestDocumentsToClear'])->getMock();
     $this->sourceAdapter = $this->getMockBuilder('Migration\\ResourceModel\\Adapter\\Mysql')->disableOriginalConstructor()->setMethods(['getSelect', 'loadDataFromSelect'])->getMock();
     $select = $this->getMockBuilder('Magento\\Framework\\DB\\Select')->setMethods(['from', 'joinLeft', 'where', 'group'])->disableOriginalConstructor()->getMock();
     $select->expects($this->any())->method('from')->willReturnSelf();
     $select->expects($this->any())->method('joinLeft')->willReturnSelf();
     $select->expects($this->any())->method('where')->willReturnSelf();
     $select->expects($this->any())->method('group')->willReturnSelf();
     $this->sourceAdapter->expects($this->any())->method('getSelect')->willReturn($select);
     $this->source->expects($this->any())->method('getAdapter')->willReturn($this->sourceAdapter);
     $this->source->expects($this->any())->method('addDocumentPrefix')->willReturn($this->returnArgument(1));
     $this->source->expects($this->any())->method('getPageSize')->willReturn(100);
     /** @var \Migration\Reader\MapFactory|\PHPUnit_Framework_MockObject_MockObject $mapFactory */
     $mapFactory = $this->getMock('\\Migration\\Reader\\MapFactory', [], [], '', false);
     $mapFactory->expects($this->any())->method('create')->with('log_map_file')->willReturn($this->map);
     $this->readerGroups = $this->getMock('\\Migration\\Reader\\Groups', ['getGroup'], [], '', false);
     $this->readerGroups->expects($this->any())->method('getGroup')->willReturnMap([['source_documents', ['source_document' => '']], ['destination_documents_to_clear', ['source_document_to_clear' => '']]]);
     /** @var \Migration\Reader\GroupsFactory|\PHPUnit_Framework_MockObject_MockObject $groupsFactory */
     $groupsFactory = $this->getMock('\\Migration\\Reader\\GroupsFactory', ['create'], [], '', false);
     $groupsFactory->expects($this->any())->method('create')->with('log_document_groups_file')->willReturn($this->readerGroups);
     $this->logger = $this->getMockBuilder('Migration\\Logger\\Logger')->disableOriginalConstructor()->setMethods(['debug'])->getMock();
     $this->data = new Data($this->progress, $this->source, $this->destination, $this->recordFactory, $this->recordTransformerFactory, $mapFactory, $groupsFactory, $this->logger);
 }
 /**
  * {@inheritdoc}
  */
 public function run()
 {
     do {
         /** @var StepList $steps */
         $steps = $this->stepListFactory->create(['mode' => 'delta']);
         /**
          * @var string $stepName
          * @var StageInterface[] $step
          */
         foreach ($steps->getSteps() as $stepName => $step) {
             if (empty($step['delta'])) {
                 continue;
             }
             $this->runDelta($step, $stepName);
             if (!empty($step['volume'])) {
                 $this->runVolume($step, $stepName);
             }
         }
         $deltaLogs = $this->groupsReader->getGroups();
         foreach ($deltaLogs as $deltaDocuments) {
             foreach (array_keys($deltaDocuments) as $documentName) {
                 /** @var Mysql $adapter */
                 $adapter = $this->source->getAdapter();
                 $adapter->deleteProcessedRecords($this->source->addDocumentPrefix($this->source->getDeltaLogName($documentName)));
             }
         }
         $this->logger->info('Migration completed successfully');
         if ($this->autoRestart) {
             $this->logger->info("Automatic restart in {$this->autoRestart} sec. Use CTRL-C to abort");
             sleep($this->autoRestart);
         }
     } while ($this->autoRestart);
     return true;
 }
 /**
  * @return void
  */
 public function setUp()
 {
     $this->config = $this->getMockBuilder('Migration\\Config')->disableOriginalConstructor()->setMethods(['getSource'])->getMock();
     $this->config->expects($this->any())->method('getSource')->will($this->returnValue(['type' => DatabaseStage::SOURCE_TYPE]));
     $this->source = $this->getMockBuilder('Migration\\ResourceModel\\Source')->disableOriginalConstructor()->setMethods(['getDocument', 'getRecordsCount', 'getAdapter', 'addDocumentPrefix', 'getRecords'])->getMock();
     $this->source->expects($this->any())->method('addDocumentPrefix')->willReturnCallback(function ($name) {
         return 'source_suffix_' . $name;
     });
     $this->destination = $this->getMockBuilder('Migration\\ResourceModel\\Destination')->disableOriginalConstructor()->setMethods(['getDocument', 'getRecordsCount', 'getAdapter', 'addDocumentPrefix', 'saveRecords'])->getMock();
     $this->destination->expects($this->any())->method('addDocumentPrefix')->willReturnCallback(function ($name) {
         return 'destination_suffix_' . $name;
     });
     $this->progress = $this->getMockBuilder('Migration\\App\\ProgressBar\\LogLevelProcessor')->disableOriginalConstructor()->setMethods(['start', 'finish', 'advance'])->getMock();
     $this->progress->expects($this->any())->method('start');
     $this->progress->expects($this->any())->method('finish');
     $this->progress->expects($this->any())->method('advance');
     $this->recordFactory = $this->getMockBuilder('Migration\\ResourceModel\\RecordFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $this->logger = $this->getMockBuilder('Migration\\Logger\\Logger')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $this->map = $this->getMockBuilder('Migration\\Reader\\Map')->disableOriginalConstructor()->setMethods(['getDocumentMap', 'init', 'getDocumentList', 'getDestDocumentsToClear'])->getMock();
     /** @var \Migration\Reader\MapFactory|\PHPUnit_Framework_MockObject_MockObject $mapFactory */
     $mapFactory = $this->getMockBuilder('Migration\\Reader\\MapFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $mapFactory->expects($this->any())->method('create')->with('customer_attr_map_file')->willReturn($this->map);
     $this->groups = $this->getMockBuilder('Migration\\Reader\\Groups')->disableOriginalConstructor()->getMock();
     $this->groups->expects($this->any())->method('getGroup')->with('source_documents')->willReturn(['source_document_1' => 'entity_id']);
     /** @var \Migration\Reader\GroupsFactory|\PHPUnit_Framework_MockObject_MockObject $groupsFactory */
     $groupsFactory = $this->getMockBuilder('Migration\\Reader\\GroupsFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $groupsFactory->expects($this->any())->method('create')->with('customer_attr_document_groups_file')->willReturn($this->groups);
     $this->logger = $this->getMockBuilder('Migration\\Logger\\Logger')->disableOriginalConstructor()->setMethods(['debug'])->getMock();
     $this->step = new Data($this->config, $this->source, $this->destination, $this->progress, $this->recordFactory, $mapFactory, $groupsFactory, $this->logger);
 }
Exemple #4
0
 /**
  * @return bool
  */
 public function perform()
 {
     $this->progress->start(count($this->groups->getGroup('documents')));
     $this->validateAttributes();
     $this->validateAttributeSetsAndGroups();
     $this->progress->finish();
     return $this->checkForErrors();
 }
 /**
  * @return void
  */
 public function setUp()
 {
     $this->groups = $this->getMockBuilder('Migration\\Reader\\Groups')->disableOriginalConstructor()->setMethods(['getGroup'])->getMock();
     $this->groups->expects($this->once())->method('getGroup')->with('destination_documents_update_on_duplicate')->willReturn([$this->fieldsUpdateOnDuplicate['document'] => implode(',', $this->fieldsUpdateOnDuplicate['fields'])]);
     /** @var \Migration\Reader\GroupsFactory|\PHPUnit_Framework_MockObject_MockObject $groupsFactory */
     $groupsFactory = $this->getMockBuilder('Migration\\Reader\\GroupsFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $groupsFactory->expects($this->any())->method('create')->with('map_document_groups')->willReturn($this->groups);
     $this->helper = new Helper($groupsFactory);
 }
 /**
  * @return bool
  */
 public function perform()
 {
     $this->progress->start(count($this->groups->getGroup('documents')));
     $this->validateAttributes();
     $this->validateAttributeSetsAndGroups();
     $this->progress->finish();
     $result = $this->checkForErrors(Logger::ERROR);
     if ($result) {
         $this->helper->deleteBackups();
     }
     return $result;
 }
 /**
  * @return bool
  */
 public function perform()
 {
     $deltaLogs = $this->groupsReader->getGroups();
     $this->progress->start(count($deltaLogs, 1) - count($deltaLogs));
     foreach ($deltaLogs as $deltaDocuments) {
         foreach ($deltaDocuments as $documentName => $idKey) {
             $this->progress->advance();
             if ($this->source->getDocument($documentName)) {
                 $this->source->createDelta($documentName, $idKey);
             }
         }
     }
     $this->progress->finish();
     return true;
 }
 /**
  * @throws \Zend_Db_Adapter_Exception
  * @return void
  */
 public function updateEavAttributes()
 {
     /** @var Mysql $adapter */
     $adapter = $this->destination->getAdapter();
     $query = $adapter->getSelect()->from($this->destination->addDocumentPrefix('eav_entity_type'), ['entity_type_id', 'entity_type_code']);
     $entityTypes = $query->getAdapter()->fetchAll($query);
     $entityTypesByCode = [];
     foreach ($entityTypes as $entityType) {
         $entityTypesByCode[$entityType['entity_type_code']] = $entityType['entity_type_id'];
     }
     $where = [];
     $entities = array_keys($this->readerGroups->getGroup('eav_entities'));
     foreach ($entities as $entity) {
         $documents = $this->readerGroups->getGroup($entity);
         $codes = [];
         foreach ($documents as $document => $key) {
             if ($key != 'entity_id') {
                 continue;
             }
             $codes = implode("','", array_keys($this->readerAttributes->getGroup($document)));
         }
         $where += [sprintf("attribute_code IN ('%s')", $codes), sprintf("entity_type_id = '%s'", $entityTypesByCode[$entity])];
     }
     $adapter->getSelect()->getAdapter()->update($this->destination->addDocumentPrefix('eav_attribute'), ['backend_type' => 'static'], $where);
 }
 /**
  * @return void
  */
 public function testDeleteBackups()
 {
     $this->readerGroups->expects($this->once())->method('getGroup')->with('documents')->willReturn(['some_document' => 0]);
     $this->map->expects($this->once())->method('getDocumentMap')->with('some_document', MapInterface::TYPE_SOURCE)->will($this->returnValue('some_dest_document'));
     $this->destination->expects($this->once())->method('deleteDocumentBackup')->with('some_dest_document');
     $this->helper->deleteBackups();
 }
 /**
  * @return void
  */
 public function setUp()
 {
     $this->logger = $this->getMock('\\Migration\\Logger\\Logger', ['debug', 'error'], [], '', false);
     $this->source = $this->getMock('\\Migration\\ResourceModel\\Source', ['getDocumentList', 'getDocument'], [], '', false);
     $this->progress = $this->getMock('\\Migration\\App\\ProgressBar\\LogLevelProcessor', ['start', 'finish', 'advance'], [], '', false);
     $this->destination = $this->getMock('\\Migration\\ResourceModel\\Destination', ['getDocumentList', 'getDocument'], [], '', false);
     $this->map = $this->getMockBuilder('\\Migration\\Reader\\Map')->disableOriginalConstructor()->getMock();
     /** @var \Migration\Reader\MapFactory|\PHPUnit_Framework_MockObject_MockObject $mapFactory */
     $mapFactory = $this->getMock('\\Migration\\Reader\\MapFactory', [], [], '', false);
     $mapFactory->expects($this->any())->method('create')->with('log_map_file')->willReturn($this->map);
     $this->readerGroups = $this->getMock('\\Migration\\Reader\\Groups', ['getGroup'], [], '', false);
     $this->readerGroups->expects($this->any())->method('getGroup')->willReturnMap([['source_documents', ['document1' => '']], ['destination_documents_to_clear', ['document_to_clear' => '']]]);
     /** @var \Migration\Reader\GroupsFactory|\PHPUnit_Framework_MockObject_MockObject $groupsFactory */
     $groupsFactory = $this->getMock('\\Migration\\Reader\\GroupsFactory', ['create'], [], '', false);
     $groupsFactory->expects($this->any())->method('create')->with('log_document_groups_file')->willReturn($this->readerGroups);
     $this->log = new Integrity($this->progress, $this->logger, $this->source, $this->destination, $mapFactory, $groupsFactory);
 }
Exemple #11
0
 /**
  * Get iterations count for step
  *
  * @return int
  */
 protected function getIterationsCount()
 {
     $iterations = 0;
     foreach (array_keys($this->readerGroups->getGroup('source_documents')) as $document) {
         $iterations += $this->source->getRecordsCount($document);
     }
     return $iterations;
 }
 /**
  * Delete backed up documents
  * @return void
  */
 public function deleteBackups()
 {
     foreach (array_keys($this->readerGroups->getGroup('documents')) as $documentName) {
         $documentName = $this->map->getDocumentMap($documentName, MapInterface::TYPE_SOURCE);
         if ($documentName) {
             $this->destination->deleteDocumentBackup($documentName);
         }
     }
 }
 /**
  * Rollback backed up documents
  * @return void
  */
 public function rollback()
 {
     foreach (array_keys($this->readerGroups->getGroup('documents')) as $documentName) {
         $destinationDocument = $this->destination->getDocument($this->map->getDocumentMap($documentName, MapInterface::TYPE_SOURCE));
         if ($destinationDocument !== false) {
             $this->destination->rollbackDocument($destinationDocument->getName());
         }
     }
 }
 /**
  * @return void
  */
 public function setUp()
 {
     $this->source = $this->getMock('\\Migration\\ResourceModel\\Source', [], [], '', false);
     $this->logger = $this->getMock('\\Migration\\Logger\\Logger', [], [], '', false);
     $this->map = $this->getMock('\\Migration\\Reader\\Map', [], [], '', false);
     /** @var \Migration\Reader\MapFactory|\PHPUnit_Framework_MockObject_MockObject $mapFactory */
     $mapFactory = $this->getMock('\\Migration\\Reader\\MapFactory', [], [], '', false);
     $mapFactory->expects($this->any())->method('create')->with('map_file')->willReturn($this->map);
     $this->destination = $this->getMock('\\Migration\\ResourceModel\\Destination', ['getAdapter'], [], '', false);
     $this->recordFactory = $this->getMock('\\Migration\\ResourceModel\\RecordFactory', [], [], '', false);
     $this->recordTransformerFactory = $this->getMock('\\Migration\\RecordTransformerFactory', [], [], '', false);
     $this->data = $this->getMock('\\Migration\\Step\\Map\\Data', [], [], '', false);
     $this->readerGroups = $this->getMock('\\Migration\\Reader\\Groups', ['getGroup'], [], '', false);
     $this->readerGroups->expects($this->any())->method('getGroup')->willReturnMap([['delta_map', ['orders' => 'order_id']]]);
     /** @var \Migration\Reader\GroupsFactory|\PHPUnit_Framework_MockObject_MockObject $groupsFactory */
     $groupsFactory = $this->getMock('\\Migration\\Reader\\GroupsFactory', ['create'], [], '', false);
     $groupsFactory->expects($this->any())->method('create')->with('delta_document_groups_file')->willReturn($this->readerGroups);
     $this->delta = new Delta($this->source, $mapFactory, $groupsFactory, $this->logger, $this->destination, $this->recordFactory, $this->recordTransformerFactory, $this->data);
 }
Exemple #15
0
 public function setUp()
 {
     $this->progress = $this->getMock('\\Migration\\App\\ProgressBar\\LogLevelProcessor', ['start', 'finish', 'advance'], [], '', false);
     $this->source = $this->getMock('Migration\\Resource\\Source', ['getDocument', 'getDocumentList', 'getRecords', 'getRecordsCount'], [], '', false);
     $this->destination = $this->getMock('Migration\\Resource\\Destination', ['getDocument', 'getDocumentList', 'saveRecords', 'clearDocument'], [], '', false);
     $this->recordFactory = $this->getMock('Migration\\Resource\\RecordFactory', ['create'], [], '', false);
     $this->recordTransformerFactory = $this->getMock('Migration\\RecordTransformerFactory', ['create'], [], '', false);
     $this->map = $this->getMockBuilder('Migration\\Reader\\Map')->disableOriginalConstructor()->setMethods(['getDocumentMap', 'init', 'getDocumentList', 'getDestDocumentsToClear'])->getMock();
     /** @var \Migration\Reader\MapFactory|\PHPUnit_Framework_MockObject_MockObject $mapFactory */
     $mapFactory = $this->getMock('\\Migration\\Reader\\MapFactory', [], [], '', false);
     $mapFactory->expects($this->any())->method('create')->with('log_map_file')->willReturn($this->map);
     $this->readerGroups = $this->getMock('\\Migration\\Reader\\Groups', ['getGroup'], [], '', false);
     $this->readerGroups->expects($this->any())->method('getGroup')->willReturnMap([['source_documents', ['source_document' => '']], ['destination_documents_to_clear', ['source_document_to_clear' => '']]]);
     /** @var \Migration\Reader\GroupsFactory|\PHPUnit_Framework_MockObject_MockObject $groupsFactory */
     $groupsFactory = $this->getMock('\\Migration\\Reader\\GroupsFactory', ['create'], [], '', false);
     $groupsFactory->expects($this->any())->method('create')->with('log_document_groups_file')->willReturn($this->readerGroups);
     $this->logger = $this->getMockBuilder('Migration\\Logger\\Logger')->disableOriginalConstructor()->setMethods(['debug'])->getMock();
     $this->data = new Data($this->progress, $this->source, $this->destination, $this->recordFactory, $this->recordTransformerFactory, $mapFactory, $groupsFactory, $this->logger);
 }
 /**
  * Volume check
  *
  * @return bool
  */
 public function perform()
 {
     $sourceDocuments = array_keys($this->groups->getGroup('source_documents'));
     $this->progress->start(count($sourceDocuments));
     foreach ($sourceDocuments as $sourceName) {
         $this->progress->advance();
         $destinationName = $this->map->getDocumentMap($sourceName, MapInterface::TYPE_SOURCE);
         $sourceFields = $this->source->getDocument($sourceName)->getStructure()->getFields();
         $destinationFields = $this->destination->getDocument($destinationName)->getStructure()->getFields();
         if (!empty(array_diff_key($sourceFields, $destinationFields))) {
             $this->errors[] = 'Mismatch of fields in the document: ' . $destinationName;
         }
         if ($this->source->getRecordsCount($sourceName) != $this->destination->getRecordsCount($destinationName)) {
             $this->errors[] = 'Mismatch of entities in the document: ' . $destinationName;
         }
     }
     $this->progress->finish();
     return $this->checkForErrors();
 }
 /**
  * Init EAV attributes
  * @return void
  */
 protected function getAttributeType()
 {
     $entities = [self::ENTITY => ''];
     $documentGroups = [self::ATTRIBUTE => ''];
     $this->readerGroups->expects($this->at(0))->method('getGroup')->with('eav_entities')->willReturn($entities);
     $this->readerGroups->expects($this->at(1))->method('getGroup')->with(self::ENTITY)->willReturn($this->sourceDocuments);
     $this->source->expects($this->any())->method('getAdapter')->willReturn($this->adapter);
     $this->adapter->expects($this->at(1))->method('fetchAll')->with($this->select)->willReturn($this->attribute);
     $this->readerAttributes->expects($this->any())->method('getGroup')->willReturn($documentGroups);
     $this->helper->getAttributeType(self::DOCUMENT);
 }
 /**
  * {@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 #19
0
 public function testPerformWithError()
 {
     $fields = ['field1' => ['DATA_TYPE' => 'int']];
     $this->map->expects($this->atLeastOnce())->method('getDocumentMap')->willReturnMap([['source_document', MapInterface::TYPE_SOURCE, 'source_document'], ['common_document', MapInterface::TYPE_SOURCE, 'common_document'], ['source_document', MapInterface::TYPE_DEST, 'source_document'], ['common_document', MapInterface::TYPE_DEST, 'common_document']]);
     $structure = $this->getMockBuilder('\\Migration\\Resource\\Structure')->disableOriginalConstructor()->setMethods([])->getMock();
     $structure->expects($this->any())->method('getFields')->will($this->returnValue($fields));
     $document = $this->getMockBuilder('\\Migration\\Resource\\Document')->disableOriginalConstructor()->getMock();
     $document->expects($this->any())->method('getStructure')->will($this->returnValue($structure));
     $this->source->expects($this->atLeastOnce())->method('getDocumentList')->will($this->returnValue(['source_document', 'common_document']));
     $this->source->expects($this->atLeastOnce())->method('getDocument')->willReturn($document);
     $this->destination->expects($this->atLeastOnce())->method('getDocumentList')->will($this->returnValue(['common_document']));
     $this->destination->expects($this->atLeastOnce())->method('getDocument')->willReturn($document);
     $this->logger->expects($this->once())->method('error')->with('Source documents not mapped: source_document');
     $this->readerGroups->expects($this->any())->method('getGroup')->with('documents')->willReturn(['source_document' => 0, 'common_document' => 1]);
     $this->assertFalse($this->integrity->perform());
 }
 /**
  * {@inheritdoc}
  */
 public function perform()
 {
     $sourceDocuments = array_keys($this->readerGroups->getGroup('source_documents'));
     $this->progress->start(count($sourceDocuments), LogManager::LOG_LEVEL_INFO);
     $this->helper->initEavEntityCollection('catalog_category_entity_varchar');
     foreach ($sourceDocuments as $sourceDocName) {
         $this->progress->advance(LogManager::LOG_LEVEL_INFO);
         $sourceDocument = $this->source->getDocument($sourceDocName);
         $destinationName = $this->map->getDocumentMap($sourceDocName, MapInterface::TYPE_SOURCE);
         if (!$destinationName) {
             continue;
         }
         $destDocument = $this->destination->getDocument($destinationName);
         $this->destination->clearDocument($destinationName);
         $this->logger->debug('migrating', ['table' => $sourceDocName]);
         $recordTransformer = $this->recordTransformerFactory->create(['sourceDocument' => $sourceDocument, 'destDocument' => $destDocument, 'mapReader' => $this->map]);
         $recordTransformer->init();
         $this->progress->start(ceil($this->source->getRecordsCount($sourceDocName) / $this->source->getPageSize($sourceDocName)), LogManager::LOG_LEVEL_DEBUG);
         $pageNumber = 0;
         while (!empty($items = $this->source->getRecords($sourceDocName, $pageNumber))) {
             $pageNumber++;
             $destinationRecords = $destDocument->getRecords();
             foreach ($items as $data) {
                 /** @var Record $record */
                 $record = $this->recordFactory->create(['document' => $sourceDocument, 'data' => $data]);
                 /** @var Record $destRecord */
                 $destRecord = $this->recordFactory->create(['document' => $destDocument]);
                 $recordTransformer->transform($record, $destRecord);
                 $destinationRecords->addRecord($destRecord);
                 $this->helper->updateAttributeData($data);
             }
             $this->source->setLastLoadedRecord($sourceDocName, end($items));
             $this->progress->advance(LogManager::LOG_LEVEL_DEBUG);
             $this->destination->saveRecords($destinationName, $destinationRecords);
         }
         $this->progress->finish(LogManager::LOG_LEVEL_DEBUG);
     }
     $this->helper->saveRecords();
     $this->helper->updateEavAttributes();
     $this->progress->finish(LogManager::LOG_LEVEL_INFO);
     return true;
 }
 /**
  * @param GroupsFactory $groupsFactory
  */
 public function __construct(GroupsFactory $groupsFactory)
 {
     $this->readerGroups = $groupsFactory->create('map_document_groups');
     $this->documentsDuplicateOnUpdate = $this->readerGroups->getGroup('destination_documents_update_on_duplicate');
 }
 /**
  * Get iterations count for step
  *
  * @return int
  */
 protected function getIterationsCount()
 {
     return count($this->readerGroups->getGroup('source_documents'));
 }
 /**
  * {@inheritdoc}
  */
 protected function getIterationsCount()
 {
     return count($this->readerGroups->getGroup('destination_documents_to_clear')) + count($this->readerGroups->getGroup('source_documents')) * 2;
 }
Exemple #24
0
 /**
  * Returns number of iterations for integrity check
  * @return mixed
  */
 protected function getIterationsCount()
 {
     return count($this->groups->getGroup('documents')) * 2;
 }