Пример #1
0
 /**
  * @return bool
  */
 public function perform()
 {
     // catalog_product_entity_tier_price should be migrated first to save same value_id as into magento1
     $sourceDocuments = array_keys($this->helper->getSourceDocumentFields());
     $this->progress->start(count($sourceDocuments), LogManager::LOG_LEVEL_INFO);
     $destinationName = $this->helper->getDestinationName();
     $this->destination->clearDocument($destinationName);
     $destDocument = $this->destination->getDocument($destinationName);
     foreach ($sourceDocuments as $sourceDocName) {
         $pageNumber = 0;
         $this->logger->debug('migrating', ['table' => $sourceDocName]);
         $this->progress->start($this->source->getRecordsCount($sourceDocName), LogManager::LOG_LEVEL_DEBUG);
         while (!empty($items = $this->source->getRecords($sourceDocName, $pageNumber))) {
             $pageNumber++;
             $destinationRecords = $destDocument->getRecords();
             foreach ($items as $recordData) {
                 unset($recordData['value_id']);
                 $this->progress->advance(LogManager::LOG_LEVEL_INFO);
                 $this->progress->advance(LogManager::LOG_LEVEL_DEBUG);
                 /** @var Record $destRecord */
                 $destRecord = $this->recordFactory->create(['document' => $destDocument, 'data' => $recordData]);
                 $destinationRecords->addRecord($destRecord);
             }
             $this->destination->saveRecords($destinationName, $destinationRecords);
         }
         $this->progress->finish(LogManager::LOG_LEVEL_DEBUG);
     }
     $this->progress->finish(LogManager::LOG_LEVEL_INFO);
     return true;
 }
Пример #2
0
 /**
  * {@inheritdoc}
  */
 public function perform()
 {
     $this->progress->start(count($this->helper->getDocumentList()));
     $documents = $this->helper->getDocumentList();
     foreach ($documents as $sourceDocName => $destDocName) {
         $this->progress->advance();
         $sourceDocument = $this->source->getDocument($sourceDocName);
         $destinationDocument = $this->destination->getDocument($destDocName);
         $this->destination->clearDocument($destDocName);
         $pageNumber = 0;
         while (!empty($sourceRecords = $this->source->getRecords($sourceDocName, $pageNumber))) {
             $pageNumber++;
             $recordsToSave = $destinationDocument->getRecords();
             foreach ($sourceRecords as $recordData) {
                 /** @var ResourceModel\Record $destinationRecord */
                 $destinationRecord = $this->recordFactory->create(['document' => $destinationDocument]);
                 if ($this->haveEqualStructure($sourceDocument, $destinationDocument)) {
                     $destinationRecord->setData($recordData);
                 } else {
                     $destinationRecord = $this->transformRecord($destinationRecord, $recordData);
                 }
                 $recordsToSave->addRecord($destinationRecord);
             }
             $this->destination->saveRecords($destinationDocument->getName(), $recordsToSave);
         }
     }
     $this->progress->finish();
     return true;
 }
 /**
  * {@inheritdoc}
  */
 public function perform()
 {
     $this->progress->start(1);
     $this->progress->advance();
     $ratingsShouldBeActive = [];
     $ratingsIsActive = [];
     /** @var \Migration\ResourceModel\Adapter\Mysql $adapter */
     $adapter = $this->destination->getAdapter();
     /** @var \Magento\Framework\DB\Select $select */
     $select = $adapter->getSelect()->from($this->getRatingStoreDocument(), ['rating_id'])->where('store_id > 0');
     $ratingsStore = $adapter->loadDataFromSelect($select);
     foreach ($ratingsStore as $rating) {
         $ratingsShouldBeActive[] = $rating['rating_id'];
     }
     $ratingsShouldBeActive = array_unique($ratingsShouldBeActive);
     /** @var \Magento\Framework\DB\Select $select */
     $select = $adapter->getSelect()->from($this->getRatingDocument(), ['rating_id'])->where('is_active = ?', 1);
     $ratings = $adapter->loadDataFromSelect($select);
     foreach ($ratings as $rating) {
         $ratingsIsActive[] = $rating['rating_id'];
     }
     if (count(array_intersect($ratingsShouldBeActive, $ratingsIsActive)) != count($ratingsShouldBeActive)) {
         $this->errors[] = sprintf('Mismatch of entities in the documents: %s, %s', self::RATING_TABLE_NAME, self::RATING_STORE_TABLE_NAME);
     }
     $this->progress->finish();
     return $this->checkForErrors(Logger::ERROR);
 }
 /**
  * {@inheritdoc}
  */
 public function perform()
 {
     $result = true;
     $this->progress->start(count($this->helper->getDocumentList()));
     foreach ($this->helper->getDocumentList() as $sourceName => $destinationName) {
         $this->progress->advance();
         $result &= (bool) $this->source->getDocument($sourceName);
         $result &= (bool) $this->destination->getDocument($destinationName);
     }
     $this->progress->finish();
     return (bool) $result;
 }
 /**
  * @param array $fieldsData
  * @param string $sourceType
  * @return void
  */
 protected function checkFields($fieldsData, $sourceType)
 {
     $resourceModel = $this->getResourceModel($sourceType);
     foreach ($fieldsData as $field => $documentName) {
         $this->progress->advance();
         $document = $resourceModel->getDocument($documentName);
         $structure = array_keys($document->getStructure()->getFields());
         if (!in_array($field, $structure)) {
             $this->missingDocumentFields[$sourceType][$documentName][] = $field;
         }
     }
 }
 /**
  * {@inheritdoc}
  */
 public function perform()
 {
     $this->progress->start(count($this->helper->getDocumentList()));
     foreach ($this->helper->getDocumentList() as $sourceName => $destinationName) {
         $this->progress->advance();
         if ($this->source->getRecordsCount($sourceName) != $this->destination->getRecordsCount($destinationName)) {
             $this->errors[] = 'Mismatch of entities in the document: ' . $destinationName;
         }
     }
     $this->progress->finish();
     return $this->checkForErrors(Logger::ERROR);
 }
Пример #7
0
 /**
  * @param array $fieldsData
  * @param string $sourceType
  * @return void
  */
 protected function check($fieldsData, $sourceType)
 {
     $source = $this->getResource($sourceType);
     foreach ($fieldsData as $field => $documentName) {
         $this->progress->advance();
         $document = $source->getDocument($documentName);
         $structure = array_keys($document->getStructure()->getFields());
         if (!in_array($field, $structure)) {
             $message = sprintf('%s table does not contain field: %s', $document, $field);
             $this->logger->error($message);
         }
     }
 }
Пример #8
0
 /**
  * @return bool
  */
 public function perform()
 {
     $this->progressBar->start($this->getIterationsCount());
     foreach ($this->helper->getDocumentList() as $sourceDocumentName => $destinationDocumentName) {
         $this->progressBar->advance();
         $sourceRecordsCount = $this->source->getRecordsCount($sourceDocumentName);
         $destinationRecordsCount = $this->destination->getRecordsCount($destinationDocumentName);
         if ($sourceRecordsCount != $destinationRecordsCount) {
             $this->errors[] = 'Mismatch of entities in the document: ' . $destinationDocumentName;
         }
     }
     $this->progressBar->finish();
     return $this->checkForErrors();
 }
 /**
  * {@inheritdoc}
  */
 public function perform()
 {
     $this->progress->start(count($this->helper->getSourceDocumentFields()));
     $sourceTotal = 0;
     $destinationTotal = $this->destination->getRecordsCount($this->helper->getDestinationName());
     foreach (array_keys($this->helper->getSourceDocumentFields()) as $sourceName) {
         $sourceTotal += $this->source->getRecordsCount($sourceName);
         $this->progress->advance();
     }
     if ($sourceTotal != $destinationTotal) {
         $this->errors[] = 'Mismatch of amount of entities in documents';
     }
     $this->progress->finish();
     return $this->checkForErrors(Logger::ERROR);
 }
 /**
  * @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;
 }
Пример #11
0
 /**
  * {@inheritdoc}
  */
 public function perform()
 {
     $this->progress->start($this->getIterationsCount());
     foreach ($this->helper->getDocumentList() as $documentName) {
         $this->progress->advance();
         $documentColumns = $this->helper->getDocumentColumns($documentName);
         $destinationDocumentStructure = array_keys($this->destination->getStructure($documentName)->getFields());
         foreach (array_diff($documentColumns, $destinationDocumentStructure) as $columnDiff) {
             $message = sprintf('%s table does not contain field: %s', $documentName, $columnDiff);
             $this->logger->error($message);
         }
     }
     $this->progress->finish();
     return $this->checkForErrors();
 }
Пример #12
0
 /**
  * @return bool
  */
 public function perform()
 {
     $this->helper->init();
     $this->progress->start($this->getIterationsCount(), LogManager::LOG_LEVEL_INFO);
     $document = $this->helper->getDocumentList();
     $sourceDocumentName = $document['source'];
     $destinationDocumentName = $document['destination'];
     $destinationDocument = $this->destination->getDocument($destinationDocumentName);
     $pageNumber = 0;
     $this->logger->debug('migrating', ['table' => $sourceDocumentName]);
     $this->progress->start($this->source->getRecordsCount($sourceDocumentName), LogManager::LOG_LEVEL_DEBUG);
     /** @var \Magento\Framework\DB\Select $select */
     $select = $this->getConfigurablePrice();
     while (!empty($bulk = $this->getRecords($sourceDocumentName, $select, $pageNumber))) {
         $pageNumber++;
         $destinationCollection = $destinationDocument->getRecords();
         foreach ($bulk as $recordData) {
             $this->progress->advance(LogManager::LOG_LEVEL_INFO);
             $this->progress->advance(LogManager::LOG_LEVEL_DEBUG);
             /** @var Record $destinationRecord */
             $destinationRecord = $this->recordFactory->create(['document' => $destinationDocument, 'data' => $recordData]);
             $destinationCollection->addRecord($destinationRecord);
         }
         $this->destination->saveRecords($destinationDocumentName, $destinationCollection, true);
         $this->progress->finish(LogManager::LOG_LEVEL_DEBUG);
     }
     $this->progress->finish(LogManager::LOG_LEVEL_INFO);
     return true;
 }
Пример #13
0
 /**
  * {@inheritdoc}
  */
 public function perform()
 {
     $this->progressBar->start(1, LogManager::LOG_LEVEL_INFO);
     $this->progressBar->advance(LogManager::LOG_LEVEL_INFO);
     $this->destination->clearDocument($this->helper->getSequenceMetaTable());
     $this->destination->clearDocument($this->helper->getSequenceProfileTable());
     foreach ($this->helper->getEntityTypeTablesMap() as $entityType) {
         foreach ($this->helper->getStoreIds() as $storeId) {
             $this->createSequenceTable($entityType, $storeId);
             $metaId = $this->addDataMetaTable($entityType, $storeId);
             $this->addDataProfileTable($storeId, $metaId);
         }
     }
     $this->progressBar->finish(LogManager::LOG_LEVEL_INFO);
     return true;
 }
Пример #14
0
 /**
  * {@inheritdoc}
  */
 public function perform()
 {
     $destinationDocument = $this->destination->getDocument(self::CONFIG_TABLE_NAME_DESTINATION);
     $recordsCountSource = $this->source->getRecordsCount(self::CONFIG_TABLE_NAME_SOURCE);
     $recordsCountDestination = $this->destination->getRecordsCount(self::CONFIG_TABLE_NAME_DESTINATION);
     $this->progress->start($recordsCountSource);
     $sourceRecords = $this->source->getRecords(self::CONFIG_TABLE_NAME_SOURCE, 0, $recordsCountSource);
     $destinationRecords = $this->destination->getRecords(self::CONFIG_TABLE_NAME_DESTINATION, 0, $recordsCountDestination);
     foreach ($sourceRecords as $sourceRecord) {
         $this->progress->advance();
         if (!$this->readerSettings->isNodeIgnored($sourceRecord[self::CONFIG_FIELD_PATH])) {
             $sourceRecordPathMapped = $this->readerSettings->getNodeMap($sourceRecord[self::CONFIG_FIELD_PATH]);
             foreach ($destinationRecords as &$destinationRecord) {
                 if ($destinationRecord[self::CONFIG_FIELD_SCOPE] == $sourceRecord[self::CONFIG_FIELD_SCOPE] && $destinationRecord[self::CONFIG_FIELD_SCOPE_ID] == $sourceRecord[self::CONFIG_FIELD_SCOPE_ID] && $destinationRecord[self::CONFIG_FIELD_PATH] == $sourceRecordPathMapped) {
                     $record = $this->applyHandler($destinationDocument, $sourceRecord, $destinationRecord);
                     $destinationRecord[self::CONFIG_FIELD_VALUE] = $record->getValue(self::CONFIG_FIELD_VALUE);
                     continue 2;
                 }
             }
             $record = $this->applyHandler($destinationDocument, $sourceRecord, []);
             $record->setValue(self::CONFIG_FIELD_PATH, $sourceRecordPathMapped);
             $destinationRecords[] = $record->getData();
         }
     }
     foreach ($destinationRecords as &$destinationRecord) {
         unset($destinationRecord[self::CONFIG_FIELD_CONFIG_ID]);
     }
     $this->destination->clearDocument(self::CONFIG_TABLE_NAME_DESTINATION);
     $this->destination->saveRecords(self::CONFIG_TABLE_NAME_DESTINATION, $destinationRecords);
     $this->progress->finish();
     return true;
 }
Пример #15
0
 /**
  * @return bool
  */
 public function perform()
 {
     $sourceDocuments = array_keys($this->helper->getDocumentList());
     $this->progress->start(count($sourceDocuments));
     foreach ($sourceDocuments as $sourceDocName) {
         $this->progress->advance();
         $destinationName = $this->map->getDocumentMap($sourceDocName, MapInterface::TYPE_SOURCE);
         if (!$destinationName) {
             continue;
         }
         $this->checkMapEntities($sourceDocName, $destinationName);
         $this->checkEavEntities();
     }
     $this->progress->finish();
     return $this->checkForErrors();
 }
 /**
  * Check if source and destination resources have equal document names and fields
  *
  * @param array $documents
  * @param string $type - allowed values: MapInterface::TYPE_SOURCE, MapInterface::TYPE_DEST
  * @param bool $verifyFields
  * @return $this
  */
 protected function check($documents, $type, $verifyFields = true)
 {
     $documents = $this->filterIgnoredDocuments($documents, $type);
     if (!empty($documents)) {
         $this->hasMappedDocuments = false;
         $source = $type == MapInterface::TYPE_SOURCE ? $this->source : $this->destination;
         $destination = $type == MapInterface::TYPE_SOURCE ? $this->destination : $this->source;
         $destDocuments = array_flip($destination->getDocumentList());
         foreach ($documents as $sourceDocumentName) {
             $this->progress->advance();
             $destinationDocumentName = $this->map->getDocumentMap($sourceDocumentName, $type);
             $sourceDocument = $source->getDocument($sourceDocumentName);
             $destinationDocument = $destination->getDocument($destinationDocumentName);
             if (!isset($destDocuments[$destinationDocumentName]) || !$sourceDocument || !$destinationDocument) {
                 $this->missingDocuments[$type][$sourceDocumentName] = true;
             } else {
                 $this->hasMappedDocuments = true;
                 if ($verifyFields) {
                     $this->verifyFields($sourceDocument, $destinationDocument, $type);
                 }
             }
         }
     }
     return $this;
 }
Пример #17
0
 /**
  * @param array $documents
  * @return void
  */
 protected function clearLog($documents)
 {
     foreach ($documents as $documentName) {
         $this->progress->advance();
         $this->destination->clearDocument($documentName);
     }
 }
 /**
  * {@inheritdoc}
  */
 public function perform()
 {
     $this->progress->start(1);
     $this->progress->advance();
     $documents = $this->source->getDocumentList();
     if (!in_array(self::CONFIG_TABLE_NAME_SOURCE, $documents)) {
         $this->logger->error(sprintf('Integrity check failed due to "%s" document does not exist in the source resource', self::CONFIG_TABLE_NAME_SOURCE));
         return false;
     }
     $documents = $this->destination->getDocumentList();
     if (!in_array(self::CONFIG_TABLE_NAME_DESTINATION, $documents)) {
         $this->logger->error(sprintf('Integrity check failed due to "%s" document does not exist in the destination resource', self::CONFIG_TABLE_NAME_DESTINATION));
         return false;
     }
     $this->progress->finish();
     return true;
 }
 /**
  * {@inheritdoc}
  */
 public function perform()
 {
     $this->progress->start(1);
     $this->progress->advance();
     $documents = $this->destination->getDocumentList();
     if (!in_array(self::RATING_TABLE_NAME, $documents) || !in_array(self::RATING_STORE_TABLE_NAME, $documents)) {
         $this->logger->error(sprintf('"%s" or "%s" documents do not exist in the destination resource', self::RATING_TABLE_NAME, self::RATING_STORE_TABLE_NAME));
         return false;
     }
     $structureRating = $this->destination->getDocument(self::RATING_TABLE_NAME)->getStructure()->getFields();
     if (!array_key_exists('is_active', $structureRating)) {
         $this->logger->error(sprintf('"is_active" field does not exist in "%s" document of' . ' the destination resource', self::RATING_TABLE_NAME));
         return false;
     }
     $this->progress->finish();
     return true;
 }
 /**
  * @return void
  */
 protected function collectCmsPageRewrites()
 {
     $this->progress->advance();
     /** @var \Magento\Framework\Db\Select $select */
     $select = $this->source->getAdapter()->getSelect();
     $select->distinct()->from(['cp' => $this->source->addDocumentPrefix($this->cmsPageTableName)], [new \Zend_Db_Expr('"cms-page" as `entity_type`'), 'entity_id' => 'cp.page_id', 'request_path' => 'cp.identifier', 'target_path' => 'CONCAT("cms/page/view/page_id/", cp.page_id)', 'store_id' => 'IF(cps.store_id = 0, 1, cps.store_id)', new \Zend_Db_Expr('1 as `is_autogenerated`')])->joinLeft(['cps' => $this->source->addDocumentPrefix($this->cmsPageStoreTableName)], 'cps.page_id = cp.page_id', [])->group(['request_path', 'cps.store_id']);
     $urlRewrites = $this->source->getAdapter()->loadDataFromSelect($select);
     $this->destination->saveRecords(self::DESTINATION, $urlRewrites);
 }
Пример #21
0
 /**
  * @return bool
  */
 public function perform()
 {
     $sourceDocuments = array_keys($this->readerGroups->getGroup('source_documents'));
     $this->progress->start($this->getIterationsCount());
     foreach ($sourceDocuments as $sourceDocName) {
         $this->progress->advance();
         $destinationName = $this->map->getDocumentMap($sourceDocName, MapInterface::TYPE_SOURCE);
         if (!$destinationName) {
             continue;
         }
         $sourceCount = $this->helper->getSourceRecordsCount($sourceDocName);
         $destinationCount = $this->destination->getRecordsCount($destinationName);
         if ($sourceCount != $destinationCount) {
             $this->errors[] = 'Mismatch of entities in the document: ' . $destinationName;
         }
     }
     $this->progress->finish();
     return $this->checkForErrors();
 }
Пример #22
0
 /**
  * @return bool
  */
 public function perform()
 {
     $sourceDocuments = $this->source->getDocumentList();
     $this->progressBar->start(count($sourceDocuments));
     foreach ($sourceDocuments as $sourceDocName) {
         $this->progressBar->advance();
         $destinationName = $this->map->getDocumentMap($sourceDocName, MapInterface::TYPE_SOURCE);
         if (!$destinationName) {
             continue;
         }
         $sourceCount = $this->source->getRecordsCount($sourceDocName);
         $destinationCount = $this->destination->getRecordsCount($destinationName);
         if ($sourceCount != $destinationCount) {
             $this->errors[] = 'Mismatch of entities in the document: ' . $destinationName;
         }
     }
     $this->progressBar->finish();
     return $this->checkForErrors();
 }
Пример #23
0
 /**
  * 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();
 }
Пример #24
0
 /**
  * {@inheritdoc}
  */
 public function perform()
 {
     $this->progress->start(1);
     $this->progress->advance();
     if (!$this->destination->getDocument($this->helper->getSequenceProfileTable())) {
         $this->missingDocuments[MapInterface::TYPE_DEST][$this->helper->getSequenceProfileTable()] = true;
     } else {
         $structureExistingSequenceProfileTable = array_keys($this->destination->getDocument($this->helper->getSequenceProfileTable())->getStructure()->getFields());
         $this->checkStructure($this->helper->getSequenceProfileTable(), $this->helper->getSequenceProfileTable(true), $structureExistingSequenceProfileTable);
     }
     if (!$this->destination->getDocument($this->helper->getSequenceMetaTable())) {
         $this->missingDocuments[MapInterface::TYPE_DEST][$this->helper->getSequenceMetaTable()] = true;
     } else {
         $structureExistingSequenceMetaTable = array_keys($this->destination->getDocument($this->helper->getSequenceMetaTable())->getStructure()->getFields());
         $this->checkStructure($this->helper->getSequenceMetaTable(), $this->helper->getSequenceMetaTable(true), $structureExistingSequenceMetaTable);
     }
     $this->progress->finish();
     return $this->checkForErrors();
 }
Пример #25
0
 /**
  * {@inheritdoc}
  */
 public function perform()
 {
     $this->progress->start(1);
     $this->progress->advance();
     $ratingsIsActive = [];
     /** @var \Migration\ResourceModel\Adapter\Mysql $adapter */
     $adapter = $this->destination->getAdapter();
     /** @var \Magento\Framework\DB\Select $select */
     $select = $adapter->getSelect()->from($this->getRatingStoreDocument(), ['rating_id'])->where('store_id > 0');
     $ratingsStore = $adapter->loadDataFromSelect($select);
     foreach ($ratingsStore as $rating) {
         $ratingsIsActive[] = $rating['rating_id'];
     }
     $ratingsIsActive = array_unique($ratingsIsActive);
     if ($ratingsIsActive) {
         $adapter->updateDocument($this->getRatingDocument(), ['is_active' => 1], sprintf('rating_id IN (%s)', implode(',', $ratingsIsActive)));
     }
     $this->progress->finish();
     return true;
 }
Пример #26
0
 /**
  * @return bool
  */
 public function perform()
 {
     $this->progressBar->start(1);
     $this->progressBar->advance();
     /** @var \Magento\Framework\DB\Adapter\Pdo\Mysql $adapter */
     $adapter = $this->destination->getAdapter()->getSelect()->getAdapter();
     foreach ($this->helper->getEntityTypeTablesMap() as $entityType) {
         foreach ($this->helper->getStoreIds() as $storeId) {
             $incrementMaxNumber = $this->helper->getMaxIncrementForEntityType($entityType['entity_type_id']);
             $select = $adapter->select()->from($this->helper->getTableName($entityType['entity_type_table'], $storeId))->order("{$entityType['column']} DESC")->limit(1);
             $lastInsertId = $adapter->fetchOne($select);
             if ($incrementMaxNumber != $lastInsertId) {
                 $this->errors[] = sprintf('Mismatch in last increment id of %s entity', $entityType['entity_type_code']);
                 continue 2;
             }
         }
     }
     $this->progressBar->finish();
     return $this->checkForErrors();
 }
 /**
  * {@inheritdoc}
  */
 protected function volume()
 {
     $this->progress->start(1);
     $this->getRewritesSelect();
     $this->progress->advance();
     $result = $this->source->getRecordsCount($this->tableName) == $this->destination->getRecordsCount('url_rewrite');
     if (!$result) {
         $this->logger->error('Mismatch of entities in the document: url_rewrite');
     }
     $this->progress->finish();
     return $result;
 }
Пример #28
0
 /**
  * Volume check
  *
  * @return bool
  */
 protected function volume()
 {
     $result = true;
     $this->progress->start(1);
     $result &= $this->source->getRecordsCount(self::SOURCE) == $this->destination->getRecordsCount(self::DESTINATION);
     if (!$result) {
         $this->logger->warning('Mismatch of entities in the document: url_rewrite');
     }
     $this->progress->advance();
     $this->progress->finish();
     return (bool) $result;
 }
 /**
  * @param array $tableFields
  * @param string $sourceType
  * @return void
  */
 protected function checkFields($tableFields, $sourceType)
 {
     foreach ($tableFields as $documentName => $fieldsData) {
         $source = $this->getResourceModel($sourceType);
         $document = $source->getDocument($documentName);
         $structure = array_keys($document->getStructure()->getFields());
         $fieldsDiff = array_diff($fieldsData, $structure);
         if (!empty($fieldsDiff)) {
             $this->missingDocumentFields[$sourceType][$documentName] = $fieldsDiff;
         }
         $this->progress->advance();
     }
 }
Пример #30
0
 /**
  * @return bool
  */
 public function perform()
 {
     $this->progressBar->start(count($this->source->getDocumentList()), LogManager::LOG_LEVEL_INFO);
     $sourceDocuments = $this->source->getDocumentList();
     $stage = 'run';
     $processedDocuments = $this->progress->getProcessedEntities($this, $stage);
     foreach (array_diff($sourceDocuments, $processedDocuments) as $sourceDocName) {
         $this->progressBar->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->getRecordTransformer($sourceDocument, $destDocument);
         $doCopy = $recordTransformer === null && $this->copyDirectly;
         if ($doCopy && $this->isCopiedDirectly($sourceDocument, $destDocument)) {
             $this->progressBar->start(1, LogManager::LOG_LEVEL_DEBUG);
         } else {
             $pageNumber = 0;
             $this->progressBar->start(ceil($this->source->getRecordsCount($sourceDocName) / $this->source->getPageSize($sourceDocName)), LogManager::LOG_LEVEL_DEBUG);
             while (!empty($items = $this->source->getRecords($sourceDocName, $pageNumber))) {
                 $pageNumber++;
                 $destinationRecords = $destDocument->getRecords();
                 foreach ($items as $data) {
                     if ($recordTransformer) {
                         /** @var Record $record */
                         $record = $this->recordFactory->create(['document' => $sourceDocument, 'data' => $data]);
                         /** @var Record $destRecord */
                         $destRecord = $this->recordFactory->create(['document' => $destDocument]);
                         $recordTransformer->transform($record, $destRecord);
                     } else {
                         $destRecord = $this->recordFactory->create(['document' => $destDocument, 'data' => $data]);
                     }
                     $destinationRecords->addRecord($destRecord);
                 }
                 $this->source->setLastLoadedRecord($sourceDocName, end($items));
                 $this->progressBar->advance(LogManager::LOG_LEVEL_DEBUG);
                 $fieldsUpdateOnDuplicate = $this->helper->getFieldsUpdateOnDuplicate($destinationName);
                 $this->destination->saveRecords($destinationName, $destinationRecords, $fieldsUpdateOnDuplicate);
             }
         }
         $this->source->setLastLoadedRecord($sourceDocName, []);
         $this->progress->addProcessedEntity($this, $stage, $sourceDocName);
         $this->progressBar->finish(LogManager::LOG_LEVEL_DEBUG);
     }
     $this->progressBar->finish(LogManager::LOG_LEVEL_INFO);
     return true;
 }