/** * @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; }
/** * {@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); }