/**
  * Data migration
  *
  * @return bool
  * @throws \Migration\Exception
  */
 protected function data()
 {
     $this->getRewritesSelect();
     $this->progress->start($this->getIterationsCount());
     $sourceDocument = $this->source->getDocument($this->tableName);
     $destinationDocument = $this->destination->getDocument('url_rewrite');
     $destProductCategory = $this->destination->getDocument('catalog_url_rewrite_product_category');
     $duplicates = $this->getDuplicatesList();
     if (!empty($duplicates) && !empty($this->configReader->getOption('auto_resolve_urlrewrite_duplicates')) && empty($this->duplicateIndex)) {
         foreach ($duplicates as $row) {
             $this->duplicateIndex[$row['request_path']][] = $row;
         }
     }
     $pageNumber = 0;
     while (!empty($data = $this->source->getRecords($sourceDocument->getName(), $pageNumber))) {
         $pageNumber++;
         $records = $this->recordCollectionFactory->create();
         $destProductCategoryRecords = $destProductCategory->getRecords();
         foreach ($data as $row) {
             $this->progress->advance();
             $records->addRecord($this->recordFactory->create(['data' => $row]));
             $productCategoryRecord = $this->getProductCategoryRecord($destProductCategory, $row);
             if ($productCategoryRecord) {
                 $destProductCategoryRecords->addRecord($productCategoryRecord);
             }
         }
         $destinationRecords = $destinationDocument->getRecords();
         $this->migrateRewrites($records, $destinationRecords);
         $this->destination->saveRecords($destinationDocument->getName(), $destinationRecords);
         $this->destination->saveRecords($destProductCategory->getName(), $destProductCategoryRecords);
     }
     $this->copyEavData('catalog_category_entity_url_key', 'catalog_category_entity_varchar', 'category');
     $this->copyEavData('catalog_product_entity_url_key', 'catalog_product_entity_varchar', 'product');
     $this->progress->finish();
     return true;
 }
Example #2
0
 public function testGetRecords()
 {
     $recordCollection = $this->getMock('\\Migration\\Resource\\Record\\RecordCollection', [], [], '', false);
     $this->recordCollectionFactory->expects($this->atLeastOnce())->method('create')->with($this->equalTo(['structure' => $this->structure, 'documentName' => 'test_document']))->will($this->returnValue($recordCollection));
     $this->assertSame($recordCollection, $this->document->getRecords());
 }
Example #3
0
 /**
  * @return Record\Collection
  */
 public function getRecords()
 {
     return $this->recordCollectionFactory->create(['structure' => $this->structure, 'documentName' => $this->getName()]);
 }