enterprise_giftregistry/general/enabled
magento_giftregistry/general/enabled
diff --git a/etc/module.xml b/etc/module.xml
new file mode 100644
index 000000000..99505a086
--- /dev/null
+++ b/etc/module.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
diff --git a/registration.php b/registration.php
new file mode 100644
index 000000000..2111dbb29
--- /dev/null
+++ b/registration.php
@@ -0,0 +1,11 @@
+logManager = $logManager;
$this->nullOutput = $nullOutput;
- $this->consoleOutput = $consoleOutput;
+ $this->consoleOutputFactory = $consoleOutputFactory;
$this->progressBarFactory = $progressBarFactory;
$this->config = $config;
- $this->initProgressBar();
-
}
/**
- * @return void
+ * @return ProgressBar
*/
- protected function initProgressBar()
+ protected function getProgressBar()
{
- $this->progressBar = $this->progressBarFactory->create($this->getOutputInstance());
- $this->progressBar->setFormat($this->config->getOption(self::PROGRESS_BAR_FORMAT_OPTION));
+ if (null == $this->progressBar) {
+ $this->progressBar = $this->progressBarFactory->create($this->getOutputInstance());
+ $this->progressBar->setFormat($this->config->getOption(self::PROGRESS_BAR_FORMAT_OPTION));
+ }
+ return $this->progressBar;
}
/**
- * @return ConsoleOutput|NullOutput
+ * @return OutputInterface
*/
protected function getOutputInstance()
{
- if ($this->logManager->getLogLevel() == LogManager::LOG_LEVEL_ERROR) {
- return $this->nullOutput;
+ if (null == $this->consoleOutput) {
+ $this->consoleOutput = LogManager::LOG_LEVEL_ERROR == $this->logManager->getLogLevel() ?
+ $this->nullOutput :
+ $this->consoleOutputFactory->create();
}
return $this->consoleOutput;
}
@@ -102,8 +111,8 @@ public function start($max, $forceLogLevel = false)
if ($this->canRun($forceLogLevel)) {
echo PHP_EOL;
$max = ($max == 0) ? 1: $max;
- $this->progressBar->start($max);
- $this->progressBar->setOverwrite(true);
+ $this->getProgressBar()->start($max);
+ $this->getProgressBar()->setOverwrite(true);
}
}
@@ -114,7 +123,7 @@ public function start($max, $forceLogLevel = false)
public function advance($forceLogLevel = false)
{
if ($this->canRun($forceLogLevel)) {
- $this->progressBar->advance();
+ $this->getProgressBar()->advance();
}
}
@@ -125,7 +134,7 @@ public function advance($forceLogLevel = false)
public function finish($forceLogLevel = false)
{
if ($this->canRun($forceLogLevel)) {
- $this->progressBar->finish();
+ $this->getProgressBar()->finish();
}
}
diff --git a/src/Migration/App/ProgressBarFactory.php b/src/Migration/App/ProgressBarFactory.php
index 1cacbfc79..4286b9663 100644
--- a/src/Migration/App/ProgressBarFactory.php
+++ b/src/Migration/App/ProgressBarFactory.php
@@ -5,7 +5,7 @@
*/
namespace Migration\App;
-use Magento\Framework\ObjectManagerInterface;
+use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Output\OutputInterface;
/**
@@ -13,28 +13,12 @@
*/
class ProgressBarFactory
{
- /**
- * @var ObjectManagerInterface
- */
- protected $objectManager;
-
- /**
- * @param ObjectManagerInterface $objectManager
- */
- public function __construct(ObjectManagerInterface $objectManager)
- {
- $this->objectManager = $objectManager;
- }
-
/**
* @param OutputInterface $output
- * @return \Symfony\Component\Console\Helper\ProgressBar
+ * @return ProgressBar
*/
public function create(OutputInterface $output)
{
- return $this->objectManager->create(
- '\\Symfony\\Component\\Console\\Helper\\ProgressBar',
- ['output' => $output]
- );
+ return new ProgressBar($output);
}
}
diff --git a/src/Migration/App/SetupDeltaLog.php b/src/Migration/App/SetupDeltaLog.php
index bdbc0a9f0..fcf670d6e 100644
--- a/src/Migration/App/SetupDeltaLog.php
+++ b/src/Migration/App/SetupDeltaLog.php
@@ -26,6 +26,11 @@ class SetupDeltaLog implements StageInterface
*/
protected $progress;
+ /**
+ * @var \Migration\Reader\GroupsFactory
+ */
+ private $groupsFactory;
+
/**
* @param Source $source
* @param \Migration\Reader\GroupsFactory $groupsFactory
@@ -37,7 +42,7 @@ public function __construct(
ProgressBar\LogLevelProcessor $progress
) {
$this->source = $source;
- $this->groupsReader = $groupsFactory->create('delta_document_groups_file');
+ $this->groupsFactory = $groupsFactory;
$this->progress = $progress;
}
@@ -46,7 +51,7 @@ public function __construct(
*/
public function perform()
{
- $deltaLogs = $this->groupsReader->getGroups();
+ $deltaLogs = $this->getGroupsReader()->getGroups();
$this->progress->start(count($deltaLogs, 1) - count($deltaLogs));
foreach ($deltaLogs as $deltaDocuments) {
foreach ($deltaDocuments as $documentName => $idKey) {
@@ -59,4 +64,15 @@ public function perform()
$this->progress->finish();
return true;
}
+
+ /**
+ * @return Groups
+ */
+ private function getGroupsReader()
+ {
+ if (null == $this->groupsReader) {
+ $this->groupsReader = $this->groupsFactory->create('delta_document_groups_file');
+ }
+ return $this->groupsReader;
+ }
}
diff --git a/src/Migration/App/Step/AbstractIntegrity.php b/src/Migration/App/Step/AbstractIntegrity.php
index 6a4c22646..16e1cfe56 100644
--- a/src/Migration/App/Step/AbstractIntegrity.php
+++ b/src/Migration/App/Step/AbstractIntegrity.php
@@ -73,6 +73,13 @@ abstract class AbstractIntegrity implements StageInterface
*/
protected $mismatchDocumentFieldDataTypes;
+ /**
+ * Incompatible data in field of document
+ *
+ * @var array
+ */
+ protected $incompatibleDocumentFieldsData;
+
/**
* Map reader
*
@@ -202,13 +209,20 @@ protected function checkForErrors()
$checkDocuments = $this->checkDocuments();
$checkDocumentFields = $this->checkDocumentFields();
$checkMismatchDocumentFieldDataTypes = $this->checkMismatchDocumentFieldDataTypes();
- return $checkDocuments && $checkDocumentFields && $checkMismatchDocumentFieldDataTypes;
+ $checkDocumentFieldsData = $this->checkDocumentFieldsData();
+ return
+ $checkDocuments
+ && $checkDocumentFields
+ && $checkMismatchDocumentFieldDataTypes
+ && $checkDocumentFieldsData;
}
/**
+ * Check documents
+ *
* @return bool
*/
- public function checkDocuments()
+ protected function checkDocuments()
{
$check = function ($errors, $errorMessagePattern, $type) {
$isSuccess = true;
@@ -249,9 +263,11 @@ public function checkDocuments()
}
/**
+ * Check fields of document
+ *
* @return bool
*/
- public function checkDocumentFields()
+ protected function checkDocumentFields()
{
$check = function ($errors, $errorMessagePattern, $type) {
$isSuccess = true;
@@ -295,9 +311,11 @@ public function checkDocumentFields()
}
/**
+ * Check mismatch in data types of document field
+ *
* @return bool
*/
- public function checkMismatchDocumentFieldDataTypes()
+ protected function checkMismatchDocumentFieldDataTypes()
{
if (isset($this->mismatchDocumentFieldDataTypes[MapInterface::TYPE_SOURCE])) {
foreach ($this->mismatchDocumentFieldDataTypes[MapInterface::TYPE_SOURCE] as $document => $fields) {
@@ -319,4 +337,37 @@ public function checkMismatchDocumentFieldDataTypes()
}
return true;
}
+
+ /**
+ * Check data in document fields
+ *
+ * @return bool
+ */
+ protected function checkDocumentFieldsData()
+ {
+ $isSuccess = true;
+ if (isset($this->incompatibleDocumentFieldsData[MapInterface::TYPE_SOURCE])) {
+ foreach ($this->incompatibleDocumentFieldsData[MapInterface::TYPE_SOURCE] as $errorDetail) {
+ $this->logger->error(sprintf(
+ 'Incompatibility in data. Source document: %s. Field: %s. Error: %s',
+ $errorDetail['document'],
+ $errorDetail['field'],
+ $errorDetail['error']
+ ));
+ }
+ $isSuccess = false;
+ }
+ if (isset($this->incompatibleDocumentFieldsData[MapInterface::TYPE_DEST])) {
+ foreach ($this->incompatibleDocumentFieldsData[MapInterface::TYPE_DEST] as $errorDetail) {
+ $this->logger->error(sprintf(
+ 'Incompatibility in data. Destination document: %s. Field: %s. Error: %s',
+ $errorDetail['document'],
+ $errorDetail['field'],
+ $errorDetail['error']
+ ));
+ }
+ $isSuccess = false;
+ }
+ return $isSuccess;
+ }
}
diff --git a/src/Migration/Console/MigrateDataCommand.php b/src/Migration/Console/MigrateDataCommand.php
index 7e639e903..557385a81 100644
--- a/src/Migration/Console/MigrateDataCommand.php
+++ b/src/Migration/Console/MigrateDataCommand.php
@@ -19,13 +19,13 @@ class MigrateDataCommand extends AbstractMigrateCommand
* @param \Migration\Config $config
* @param \Migration\Logger\Manager $logManager
* @param \Migration\App\Progress $progress
- * @param \Migration\Mode\Data\Proxy $dataMode
+ * @param \Migration\Mode\Data $dataMode
*/
public function __construct(
\Migration\Config $config,
\Migration\Logger\Manager $logManager,
\Migration\App\Progress $progress,
- \Migration\Mode\Data\Proxy $dataMode
+ \Migration\Mode\Data $dataMode
) {
$this->dataMode = $dataMode;
parent::__construct($config, $logManager, $progress);
diff --git a/src/Migration/Console/MigrateDeltaCommand.php b/src/Migration/Console/MigrateDeltaCommand.php
index e3512557d..f79913a8f 100644
--- a/src/Migration/Console/MigrateDeltaCommand.php
+++ b/src/Migration/Console/MigrateDeltaCommand.php
@@ -19,13 +19,13 @@ class MigrateDeltaCommand extends AbstractMigrateCommand
* @param \Migration\Config $config
* @param \Migration\Logger\Manager $logManager
* @param \Migration\App\Progress $progress
- * @param \Migration\Mode\Delta\Proxy $deltaMode
+ * @param \Migration\Mode\Delta $deltaMode
*/
public function __construct(
\Migration\Config $config,
\Migration\Logger\Manager $logManager,
\Migration\App\Progress $progress,
- \Migration\Mode\Delta\Proxy $deltaMode
+ \Migration\Mode\Delta $deltaMode
) {
$this->deltaMode = $deltaMode;
parent::__construct($config, $logManager, $progress);
diff --git a/src/Migration/Console/MigrateSettingsCommand.php b/src/Migration/Console/MigrateSettingsCommand.php
index 1ce5336b1..30cf024b8 100644
--- a/src/Migration/Console/MigrateSettingsCommand.php
+++ b/src/Migration/Console/MigrateSettingsCommand.php
@@ -19,13 +19,13 @@ class MigrateSettingsCommand extends AbstractMigrateCommand
* @param \Migration\Config $config
* @param \Migration\Logger\Manager $logManager
* @param \Migration\App\Progress $progress
- * @param \Migration\Mode\Settings\Proxy $settingsMode
+ * @param \Migration\Mode\Settings $settingsMode
*/
public function __construct(
\Migration\Config $config,
\Migration\Logger\Manager $logManager,
\Migration\App\Progress $progress,
- \Migration\Mode\Settings\Proxy $settingsMode
+ \Migration\Mode\Settings $settingsMode
) {
$this->settingsMode = $settingsMode;
parent::__construct($config, $logManager, $progress);
diff --git a/src/Migration/Handler/EavAttributeGroup/SetGroupCode.php b/src/Migration/Handler/EavAttributeGroup/SetGroupCode.php
index 4de5add67..dcd36b1db 100644
--- a/src/Migration/Handler/EavAttributeGroup/SetGroupCode.php
+++ b/src/Migration/Handler/EavAttributeGroup/SetGroupCode.php
@@ -11,6 +11,7 @@
use Migration\Config;
use Migration\Exception;
use Migration\Step\DatabaseStage;
+use Migration\Model\Eav\AttributeGroupNameToCodeMap;
/**
* Class SetGroupCode
@@ -34,20 +35,26 @@ class SetGroupCode extends \Migration\Handler\AbstractHandler implements \Migrat
*/
protected $source;
+ /**
+ * @var AttributeGroupNameToCodeMap
+ */
+ private $groupNameToCodeMap;
+
/**
* @param Config $config
* @param Source $source
+ * @param AttributeGroupNameToCodeMap $groupNameToCodeMap
* @throws Exception
*/
- public function __construct(Config $config, Source $source)
+ public function __construct(Config $config, Source $source, AttributeGroupNameToCodeMap $groupNameToCodeMap)
{
+ $this->groupNameToCodeMap = $groupNameToCodeMap;
$this->canStart = $config->getSource()['type'] == DatabaseStage::SOURCE_TYPE;
$this->source = $source;
}
/**
* {@inheritdoc}
- * @SuppressWarnings(PHPMD.NPathComplexity)
*/
public function handle(Record $recordToHandle, Record $oppositeRecord)
{
@@ -60,12 +67,8 @@ public function handle(Record $recordToHandle, Record $oppositeRecord)
$recordToHandle->setValue($this->field, null);
return;
}
-
- $newValue = preg_replace('/[^a-z0-9]+/', '-', strtolower($recordToHandle->getValue('attribute_group_name')));
- $newValue = ($newValue == 'migration-general') ? 'product-details' : $newValue;
- $newValue = ($newValue == 'migration-prices') ? 'advanced-pricing' : $newValue;
- $newValue = ($newValue == 'migration-design') ? 'design' : $newValue;
- $recordToHandle->setValue($this->field, $newValue);
+ $groupCode = $this->groupNameToCodeMap->getGroupCodeMap($recordToHandle->getValue('attribute_group_name'));
+ $recordToHandle->setValue($this->field, $groupCode);
}
/**
diff --git a/src/Migration/Handler/GetEventStatus.php b/src/Migration/Handler/GetEventStatus.php
new file mode 100644
index 000000000..260d896bb
--- /dev/null
+++ b/src/Migration/Handler/GetEventStatus.php
@@ -0,0 +1,42 @@
+validate($recordToHandle);
+ $dates = [
+ 'start' => $recordToHandle->getValue('date_start'),
+ 'end' =>$recordToHandle->getValue('date_end')
+ ];
+ $currentDate = date('Y-m-d H:i:s');
+ if (($dates['start'] <= $currentDate) && ($dates['end'] > $currentDate)) {
+ $status = self::EVENT_OPEN;
+ } elseif (($dates['start'] > $currentDate) && ($dates['end'] > $currentDate)) {
+ $status = self::EVENT_UPCOMING;
+ } else {
+ $status = self::EVENT_CLOSED;
+ }
+ $recordToHandle->setValue($this->field, $status);
+ }
+}
diff --git a/src/Migration/Mode/Delta.php b/src/Migration/Mode/Delta.php
index 1522f234a..037e5f7d1 100644
--- a/src/Migration/Mode/Delta.php
+++ b/src/Migration/Mode/Delta.php
@@ -44,6 +44,11 @@ class Delta extends AbstractMode implements \Migration\App\Mode\ModeInterface
*/
protected $groupsReader;
+ /**
+ * @var \Migration\Reader\GroupsFactory
+ */
+ private $groupsFactory;
+
/**
* @param Progress $progress
* @param Logger $logger
@@ -62,7 +67,7 @@ public function __construct(
) {
$this->source = $source;
$this->autoRestart = $autoRestart;
- $this->groupsReader = $groupsFactory->create('delta_document_groups_file');
+ $this->groupsFactory = $groupsFactory;
parent::__construct($progress, $logger, $stepListFactory);
}
@@ -88,7 +93,7 @@ public function run()
}
}
- $deltaLogs = $this->groupsReader->getGroups();
+ $deltaLogs = $this->getGroupsReader()->getGroups();
foreach ($deltaLogs as $deltaDocuments) {
foreach (array_keys($deltaDocuments) as $documentName) {
/** @var Mysql $adapter */
@@ -135,4 +140,15 @@ private function runVolume(array $step, $stepName)
$this->logger->warning('Volume Check failed');
}
}
+
+ /**
+ * @return Groups
+ */
+ private function getGroupsReader()
+ {
+ if (null == $this->groupsReader) {
+ $this->groupsReader = $this->groupsFactory->create('delta_document_groups_file');
+ }
+ return $this->groupsReader;
+ }
}
diff --git a/src/Migration/Model/Eav/AttributeGroupNameToCodeMap.php b/src/Migration/Model/Eav/AttributeGroupNameToCodeMap.php
new file mode 100644
index 000000000..c8e1075c7
--- /dev/null
+++ b/src/Migration/Model/Eav/AttributeGroupNameToCodeMap.php
@@ -0,0 +1,47 @@
+ 'product-details',
+ 'Prices' => 'advanced-pricing',
+ 'Design' => 'design',
+ ];
+
+ /**
+ * @var string
+ */
+ protected $attributeGroupNamePrefix = 'Migration_';
+
+ /**
+ * @param string $groupName
+ * @return array
+ */
+ public function getGroupCodeMap($groupName)
+ {
+ $groupNameOriginal = preg_replace('/^' . $this->attributeGroupNamePrefix . '/', '', $groupName);
+ $groupCodeMap = isset($this->map[$groupNameOriginal]) ? $this->map[$groupNameOriginal] : null;
+ $groupCodeTransformed = preg_replace('/[^a-z0-9]+/', '-', strtolower($groupName));
+ $groupCode = $groupCodeMap ?: $groupCodeTransformed;
+ return $groupCode;
+ }
+
+ /**
+ * @return array
+ */
+ public function getMap()
+ {
+ return $this->map;
+ }
+}
diff --git a/src/Migration/ResourceModel/AbstractResource.php b/src/Migration/ResourceModel/AbstractResource.php
index f57e20555..e9894673e 100644
--- a/src/Migration/ResourceModel/AbstractResource.php
+++ b/src/Migration/ResourceModel/AbstractResource.php
@@ -51,6 +51,11 @@ abstract class AbstractResource
*/
protected $documentCollection;
+ /**
+ * @var AdapterFactory
+ */
+ protected $adapterFactory;
+
/**
* @var array
*/
@@ -76,7 +81,7 @@ public function __construct(
\Migration\ResourceModel\Document\Collection $documentCollection
) {
$this->configReader = $configReader;
- $this->adapter = $adapterFactory->create(['config' => $this->getResourceConfig()]);
+ $this->adapterFactory = $adapterFactory;
$this->documentFactory = $documentFactory;
$this->structureFactory = $structureFactory;
$this->documentCollection = $documentCollection;
@@ -90,12 +95,19 @@ public function __construct(
*/
public function getDocument($documentName)
{
- $documentList = $this->getDocumentList();
- if (!in_array($documentName, $documentList)) {
- return false;
+ $document = false;
+ try {
+ $structure = $this->getStructure($documentName);
+ if ($structure instanceof \Migration\ResourceModel\Structure) {
+ $document = $this->documentFactory->create(
+ ['structure' => $structure, 'documentName' => $documentName]
+ );
+ }
+ } catch (\Exception $e) {
+
}
- $structure = $this->getStructure($documentName);
- return $this->documentFactory->create(['structure' => $structure, 'documentName' => $documentName]);
+
+ return $document;
}
/**
@@ -106,7 +118,7 @@ public function getDocument($documentName)
*/
public function getStructure($documentName)
{
- $data = $this->adapter->getDocumentStructure($this->addDocumentPrefix($documentName));
+ $data = $this->getAdapter()->getDocumentStructure($this->addDocumentPrefix($documentName));
return $this->structureFactory->create(['documentName' => $documentName, 'data' => $data]);
}
@@ -117,7 +129,10 @@ public function getStructure($documentName)
*/
public function getDocumentList()
{
- $this->documentList = $this->adapter->getDocumentList();
+ if (null !== $this->documentList) {
+ return $this->documentList;
+ }
+ $this->documentList = $this->getAdapter()->getDocumentList();
foreach ($this->documentList as &$documentName) {
$documentName = $this->removeDocumentPrefix($documentName);
}
@@ -135,7 +150,7 @@ public function getDocumentList()
public function getRecordsCount($documentName, $usePrefix = true, $distinctFields = [])
{
$documentName = $usePrefix ? $this->addDocumentPrefix($documentName) : $documentName;
- return $this->adapter->getRecordsCount($documentName, $distinctFields);
+ return $this->getAdapter()->getRecordsCount($documentName, $distinctFields);
}
/**
@@ -235,7 +250,7 @@ protected function getBytes($memoryLimit)
public function getRecords($documentName, $pageNumber, $pageSize = null)
{
$pageSize = $pageSize ?: $this->getPageSize($documentName) ;
- return $this->adapter->loadPage($this->addDocumentPrefix($documentName), $pageNumber, $pageSize);
+ return $this->getAdapter()->loadPage($this->addDocumentPrefix($documentName), $pageNumber, $pageSize);
}
/**
@@ -248,7 +263,7 @@ public function getRecords($documentName, $pageNumber, $pageSize = null)
*/
public function deleteRecords($documentName, $idKey, $ids)
{
- $this->adapter->deleteRecords($documentName, $idKey, $ids);
+ $this->getAdapter()->deleteRecords($documentName, $idKey, $ids);
}
/**
@@ -258,6 +273,9 @@ public function deleteRecords($documentName, $idKey, $ids)
*/
public function getAdapter()
{
+ if (null == $this->adapter) {
+ $this->adapter = $this->adapterFactory->create(['config' => $this->getResourceConfig()]);
+ }
return $this->adapter;
}
diff --git a/src/Migration/ResourceModel/Destination.php b/src/Migration/ResourceModel/Destination.php
index c5442e78f..564420edc 100644
--- a/src/Migration/ResourceModel/Destination.php
+++ b/src/Migration/ResourceModel/Destination.php
@@ -15,6 +15,11 @@ class Destination extends AbstractResource
{
const CONFIG_DOCUMENT_PREFIX = 'dest_prefix';
+ /**
+ * @var string
+ */
+ protected $documentPrefix;
+
/**
* Save data into destination resource
*
@@ -38,13 +43,13 @@ public function saveRecords($documentName, $records, $updateOnDuplicate = false)
$data[] = $row;
}
if ($i == $pageSize) {
- $this->adapter->insertRecords($documentName, $data, $updateOnDuplicate);
+ $this->getAdapter()->insertRecords($documentName, $data, $updateOnDuplicate);
$data = [];
$i = 0;
}
}
if ($i > 0) {
- $this->adapter->insertRecords($documentName, $data, $updateOnDuplicate);
+ $this->getAdapter()->insertRecords($documentName, $data, $updateOnDuplicate);
}
return $this;
}
@@ -75,7 +80,7 @@ protected function getResourceConfig()
*/
public function clearDocument($documentName)
{
- $this->adapter->deleteAllRecords($this->addDocumentPrefix($documentName));
+ $this->getAdapter()->deleteAllRecords($this->addDocumentPrefix($documentName));
}
/**
@@ -83,7 +88,10 @@ public function clearDocument($documentName)
*/
protected function getDocumentPrefix()
{
- return $this->configReader->getOption(self::CONFIG_DOCUMENT_PREFIX);
+ if (null === $this->documentPrefix) {
+ $this->documentPrefix = $this->configReader->getOption(self::CONFIG_DOCUMENT_PREFIX);
+ }
+ return $this->documentPrefix;
}
/**
@@ -127,7 +135,7 @@ public function updateChangedRecords($documentName, $records)
$data[] = $row->getData();
}
if (!empty($data)) {
- $this->adapter->updateChangedRecords($this->addDocumentPrefix($documentName), $data);
+ $this->getAdapter()->updateChangedRecords($this->addDocumentPrefix($documentName), $data);
}
}
}
diff --git a/src/Migration/ResourceModel/Source.php b/src/Migration/ResourceModel/Source.php
index a3e64aac1..13ff5dae3 100644
--- a/src/Migration/ResourceModel/Source.php
+++ b/src/Migration/ResourceModel/Source.php
@@ -25,6 +25,11 @@ class Source extends AbstractResource
*/
protected $lastLoadedIdentityId = [];
+ /**
+ * @var string
+ */
+ protected $documentPrefix;
+
/**
* {@inheritdoc}
*/
@@ -50,7 +55,10 @@ protected function getResourceConfig()
*/
protected function getDocumentPrefix()
{
- return $this->configReader->getOption(self::CONFIG_DOCUMENT_PREFIX);
+ if (null === $this->documentPrefix) {
+ $this->documentPrefix = $this->configReader->getOption(self::CONFIG_DOCUMENT_PREFIX);
+ }
+ return $this->documentPrefix;
}
/**
@@ -62,7 +70,7 @@ protected function getDocumentPrefix()
*/
public function loadPage($documentName, $pageNumber)
{
- return $this->adapter->loadPage($documentName, $pageNumber, $this->getPageSize($documentName));
+ return $this->getAdapter()->loadPage($documentName, $pageNumber, $this->getPageSize($documentName));
}
/**
@@ -87,7 +95,7 @@ public function getRecords($documentName, $pageNumber, $pageSize = null)
}
}
- $records = $this->adapter->loadPage(
+ $records = $this->getAdapter()->loadPage(
$this->addDocumentPrefix($documentName),
$pageNumber,
$pageSize,
@@ -141,7 +149,7 @@ protected function getIdentityField($documentName)
*/
public function createDelta($documentName, $idKey)
{
- $this->adapter->createDelta(
+ $this->getAdapter()->createDelta(
$this->addDocumentPrefix($documentName),
$this->addDocumentPrefix($this->getDeltaLogName($documentName)),
$idKey
@@ -159,7 +167,7 @@ public function createDelta($documentName, $idKey)
*/
public function getChangedRecords($documentName, $idKey, $pageNumber = 0, $getProcessed = false)
{
- return $this->adapter->loadChangedRecords(
+ return $this->getAdapter()->loadChangedRecords(
$this->addDocumentPrefix($documentName),
$this->addDocumentPrefix($this->getDeltaLogName($documentName)),
$idKey,
@@ -179,7 +187,7 @@ public function getChangedRecords($documentName, $idKey, $pageNumber = 0, $getPr
*/
public function getDeletedRecords($documentName, $idKey, $getProcessed = false)
{
- return $this->adapter->loadDeletedRecords(
+ return $this->getAdapter()->loadDeletedRecords(
$this->addDocumentPrefix($this->getDeltaLogName($documentName)),
$idKey,
0,
diff --git a/src/Migration/Step/Customer/Data.php b/src/Migration/Step/Customer/Data.php
index 0f73f12bc..54abe58c3 100644
--- a/src/Migration/Step/Customer/Data.php
+++ b/src/Migration/Step/Customer/Data.php
@@ -110,10 +110,10 @@ public function __construct(
*/
public function perform()
{
- $this->progress->start($this->getIterationsCount(), LogManager::LOG_LEVEL_INFO);
$sourceDocuments = array_keys($this->readerGroups->getGroup('source_documents'));
+ $this->progress->start(count($sourceDocuments), LogManager::LOG_LEVEL_INFO);
+
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) {
@@ -156,31 +156,19 @@ public function perform()
$recordTransformer->transform($record, $destRecord);
$destinationRecords->addRecord($destRecord);
}
+
$this->progress->advance(LogManager::LOG_LEVEL_DEBUG);
$this->helper->updateAttributeData($attributeType, $sourceDocName, $destinationRecords);
$this->destination->saveRecords($destinationName, $destinationRecords);
}
+
+ $this->progress->advance(LogManager::LOG_LEVEL_INFO);
$this->progress->finish(LogManager::LOG_LEVEL_DEBUG);
}
$this->helper->updateEavAttributes();
$this->progress->finish(LogManager::LOG_LEVEL_INFO);
return true;
}
-
- /**
- * 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;
- }
}
diff --git a/src/Migration/Step/Customer/Helper.php b/src/Migration/Step/Customer/Helper.php
index 64e5a55b1..35c0910d3 100644
--- a/src/Migration/Step/Customer/Helper.php
+++ b/src/Migration/Step/Customer/Helper.php
@@ -182,17 +182,15 @@ public function setAttributeData(
/** @var Record $record */
foreach ($destinationRecords as $record) {
if (isset($recordAttributesData[$record->getValue('entity_id')])) {
+ $recordEntityData = $recordAttributesData[$record->getValue('entity_id')];
if ($this->configReader->getOption(self::UPGRADE_CUSTOMER_PASSWORD_HASH)) {
- $recordAttributesData = $this->upgradeCustomerHash(
- $recordAttributesData,
- $record->getValue('entity_id')
- );
+ $recordEntityData = $this->upgradeCustomerHash($recordEntityData);
}
$data = $record->getData();
$data = array_merge(
array_fill_keys($attributeCodes, null),
$data,
- $recordAttributesData[$record->getValue('entity_id')]
+ $recordEntityData
);
$record->setData($data);
}
@@ -347,21 +345,20 @@ public function updateEavAttributes()
* Upgrade customer hash according M2 algorithm versions
*
* @param array $recordAttributesData
- * @param string $entityId
* @return array
*/
- private function upgradeCustomerHash($recordAttributesData, $entityId)
+ private function upgradeCustomerHash($recordAttributesData)
{
- if (isset($recordAttributesData[$entityId]['password_hash'])) {
- $hash = $this->explodePasswordHash($recordAttributesData[$entityId]['password_hash']);
+ if (isset($recordAttributesData['password_hash'])) {
+ $hash = $this->explodePasswordHash($recordAttributesData['password_hash']);
if (strlen($hash[self::PASSWORD_HASH]) == 32) {
- $recordAttributesData[$entityId]['password_hash'] = implode(
+ $recordAttributesData['password_hash'] = implode(
':',
[$hash[self::PASSWORD_HASH], $hash[self::PASSWORD_SALT], '0']
);
} elseif (strlen($hash[self::PASSWORD_HASH]) == 64) {
- $recordAttributesData[$entityId]['password_hash'] = implode(
+ $recordAttributesData['password_hash'] = implode(
':',
[$hash[self::PASSWORD_HASH], $hash[self::PASSWORD_SALT], '1']
);
diff --git a/src/Migration/Step/Eav/Data.php b/src/Migration/Step/Eav/Data.php
index 214eab27b..6f81e5203 100644
--- a/src/Migration/Step/Eav/Data.php
+++ b/src/Migration/Step/Eav/Data.php
@@ -27,37 +27,40 @@
*/
class Data implements StageInterface, RollbackInterface
{
- const ENTITY_TYPE_ID_CATALOG_PRODUCT = 4;
+ /**
+ * @var array;
+ */
+ protected $newAttributeSets = [];
/**
* @var array;
*/
- protected $newAttributes;
+ protected $mapAttributeIdsDestOldNew = [];
/**
* @var array;
*/
- protected $newAttributeSets;
+ protected $mapAttributeIdsSourceDest = [];
/**
* @var array;
*/
- protected $newAttributeGroups;
+ protected $mapAttributeSetIdsDestOldNew = [];
/**
* @var array;
*/
- protected $destAttributeOldNewMap;
+ protected $mapAttributeGroupIdsDestOldNew = [];
/**
* @var array;
*/
- protected $destAttributeSetsOldNewMap;
+ protected $mapEntityTypeIdsDestOldNew = [];
/**
* @var array;
*/
- protected $destAttributeGroupsOldNewMap;
+ protected $mapEntityTypeIdsSourceDest = [];
/**
* @var Helper
@@ -99,11 +102,6 @@ class Data implements StageInterface, RollbackInterface
*/
protected $readerGroups;
- /**
- * @var \Migration\Reader\Groups
- */
- protected $readerAttributes;
-
/**
* @var array
*/
@@ -143,7 +141,6 @@ public function __construct(
$this->destination = $destination;
$this->map = $mapFactory->create('eav_map_file');
$this->readerGroups = $groupsFactory->create('eav_document_groups_file');
- $this->readerAttributes = $groupsFactory->create('eav_attribute_groups_file');
$this->helper = $helper;
$this->factory = $factory;
$this->initialData = $initialData;
@@ -158,16 +155,70 @@ public function perform()
{
$this->progress->start($this->getIterationsCount());
$this->initialData->init();
+ $this->migrateEntityTypes();
$this->migrateAttributeSetsAndGroups();
+ $this->changeOldAttributeSetIdsInEntityTypes();
$this->migrateAttributes();
+ $this->migrateAttributesExtended();
$this->migrateEntityAttributes();
- $this->migrateMappedTables();
$this->progress->finish();
return true;
}
+ /**
+ * Migrate Entity Type table
+ *
+ * @return void
+ */
+ protected function migrateEntityTypes()
+ {
+ $documentName = 'eav_entity_type';
+ $mappingField = 'entity_type_code';
+
+ $this->progress->advance();
+ $sourceDocument = $this->source->getDocument($documentName);
+ $destinationDocument = $this->destination->getDocument(
+ $this->map->getDocumentMap($documentName, MapInterface::TYPE_SOURCE)
+ );
+ $this->destination->backupDocument($destinationDocument->getName());
+ $destinationRecords = $this->helper->getDestinationRecords($documentName, [$mappingField]);
+ $recordsToSave = $destinationDocument->getRecords();
+ foreach ($this->helper->getSourceRecords($documentName) as $recordData) {
+ /** @var Record $sourceRecord */
+ $sourceRecord = $this->factory->create(['document' => $sourceDocument, 'data' => $recordData]);
+ /** @var Record $destinationRecord */
+ $destinationRecord = $this->factory->create(['document' => $destinationDocument]);
+ $mappingValue = $sourceRecord->getValue($mappingField);
+ if (isset($destinationRecords[$mappingValue])) {
+ $destinationRecordData = $destinationRecords[$mappingValue];
+ unset($destinationRecords[$mappingValue]);
+ } else {
+ $destinationRecordData = array_fill_keys($destinationRecord->getFields(), null);
+ }
+ $destinationRecord->setData($destinationRecordData);
+ $this->helper->getRecordTransformer($sourceDocument, $destinationDocument)
+ ->transform($sourceRecord, $destinationRecord);
+ $recordsToSave->addRecord($destinationRecord);
+ }
+ $this->destination->clearDocument($destinationDocument->getName());
+ $this->saveRecords($destinationDocument, $recordsToSave);
+
+ $recordsToSave = $destinationDocument->getRecords();
+ foreach ($destinationRecords as $record) {
+ $record['entity_type_id'] = null;
+ $destinationRecord = $this->factory->create([
+ 'document' => $destinationDocument,
+ 'data' => $record
+ ]);
+ $recordsToSave->addRecord($destinationRecord);
+ }
+ $this->saveRecords($destinationDocument, $recordsToSave);
+ $this->createMapEntityTypeIds();
+ }
+
/**
* Migrate eav_attribute_set and eav_attribute_group
+ *
* @return void
*/
protected function migrateAttributeSetsAndGroups()
@@ -194,6 +245,7 @@ protected function migrateAttributeSetsAndGroups()
if ($documentName == 'eav_attribute_set') {
foreach ($this->initialData->getAttributeSets('dest') as $record) {
$record['attribute_set_id'] = null;
+ $record['entity_type_id'] = $this->mapEntityTypeIdsDestOldNew[$record['entity_type_id']];
$destinationRecord = $this->factory->create(
[
'document' => $destinationDocument,
@@ -207,8 +259,9 @@ protected function migrateAttributeSetsAndGroups()
if ($documentName == 'eav_attribute_group') {
foreach ($this->initialData->getAttributeGroups('dest') as $record) {
$oldAttributeSet = $this->initialData->getAttributeSets('dest')[$record['attribute_set_id']];
+ $entityTypeId = $this->mapEntityTypeIdsDestOldNew[$oldAttributeSet['entity_type_id']];
$newAttributeSet = $this->newAttributeSets[
- $oldAttributeSet['entity_type_id'] . '-' . $oldAttributeSet['attribute_set_name']
+ $entityTypeId . '-' . $oldAttributeSet['attribute_set_name']
];
$record['attribute_set_id'] = $newAttributeSet['attribute_set_id'];
@@ -227,10 +280,10 @@ protected function migrateAttributeSetsAndGroups()
$this->destination->clearDocument($destinationDocument->getName());
$this->saveRecords($destinationDocument, $recordsToSave);
if ($documentName == 'eav_attribute_set') {
- $this->loadNewAttributeSets();
+ $this->createMapAttributeSetIds();
}
if ($documentName == 'eav_attribute_group') {
- $this->loadNewAttributeGroups();
+ $this->createMapAttributeGroupIds();
}
}
}
@@ -245,6 +298,8 @@ protected function migrateAttributeSetsAndGroups()
*/
protected function addAttributeGroups($recordsToSave, $documentName, array $groupsData)
{
+ $entityTypeIdCatalogProduct = $this->helper->getSourceRecords('eav_entity_type', ['entity_type_code'])
+ ['catalog_product']['entity_type_id'];
/** @var \Magento\Framework\DB\Select $select */
$select = $this->source->getAdapter()->getSelect();
$select->from(
@@ -252,7 +307,7 @@ protected function addAttributeGroups($recordsToSave, $documentName, array $grou
['attribute_set_id']
)->where(
'entity_type_id = ?',
- self::ENTITY_TYPE_ID_CATALOG_PRODUCT
+ $entityTypeIdCatalogProduct
);
$catalogProductSetIds = $select->getAdapter()->fetchCol($select);
$addedGroups = [];
@@ -284,8 +339,39 @@ protected function addAttributeGroups($recordsToSave, $documentName, array $grou
return $recordsToSave;
}
+ /**
+ * Change old default attribute set ids in entity types
+ *
+ * @return void
+ */
+ protected function changeOldAttributeSetIdsInEntityTypes()
+ {
+ $documentName = 'eav_entity_type';
+ $destinationDocument = $this->destination->getDocument(
+ $this->map->getDocumentMap($documentName, MapInterface::TYPE_SOURCE)
+ );
+ $recordsToSave = $destinationDocument->getRecords();
+ $entityTypesMigrated = $this->helper->getDestinationRecords($destinationDocument->getName());
+ foreach ($entityTypesMigrated as $record) {
+ if (isset($this->mapAttributeSetIdsDestOldNew[$record['default_attribute_set_id']])) {
+ $record['default_attribute_set_id'] =
+ $this->mapAttributeSetIdsDestOldNew[$record['default_attribute_set_id']];
+ }
+ $destinationRecord = $this->factory->create(
+ [
+ 'document' => $destinationDocument,
+ 'data' => $record
+ ]
+ );
+ $recordsToSave->addRecord($destinationRecord);
+ }
+ $this->destination->clearDocument($destinationDocument->getName());
+ $this->saveRecords($destinationDocument, $recordsToSave);
+ }
+
/**
* Migrate eav_attribute
+ *
* @return void
*/
protected function migrateAttributes()
@@ -297,10 +383,7 @@ protected function migrateAttributes()
$this->map->getDocumentMap($sourceDocName, MapInterface::TYPE_SOURCE)
);
$this->destination->backupDocument($destinationDocument->getName());
- $sourceRecords = $this->source->getRecords($sourceDocName, 0, $this->source->getRecordsCount($sourceDocName));
- foreach (array_keys($this->readerAttributes->getGroup('ignore')) as $attributeToClear) {
- $sourceRecords = $this->clearIgnoredAttributes($sourceRecords, $attributeToClear);
- }
+ $sourceRecords = $this->helper->clearIgnoredAttributes($this->initialData->getAttributes('source'));
$destinationRecords = $this->initialData->getAttributes('dest');
$recordsToSave = $destinationDocument->getRecords();
@@ -310,11 +393,15 @@ protected function migrateAttributes()
/** @var Record $destinationRecord */
$destinationRecord = $this->factory->create(['document' => $destinationDocument]);
- $entityTypeMappedId = $this->getEntityTypeIdMappedByCode($sourceRecord->getValue('entity_type_id'), true);
- $mappingValue = $entityTypeMappedId . '-' . $sourceRecord->getValue('attribute_code');
- if (isset($destinationRecords[$mappingValue])) {
- $destinationRecordData = $destinationRecords[$mappingValue];
- unset($destinationRecords[$mappingValue]);
+ $mappedKey = null;
+ $entityTypeId = $sourceRecord->getValue('entity_type_id');
+ if (isset($this->mapEntityTypeIdsSourceDest[$entityTypeId])) {
+ $mappedId = $this->mapEntityTypeIdsSourceDest[$entityTypeId];
+ $mappedKey = $mappedId . '-' . $sourceRecord->getValue('attribute_code');
+ }
+ if ($mappedKey && isset($destinationRecords[$mappedKey])) {
+ $destinationRecordData = $destinationRecords[$mappedKey];
+ unset($destinationRecords[$mappedKey]);
} else {
$destinationRecordData = array_fill_keys($destinationRecord->getFields(), null);
}
@@ -331,13 +418,13 @@ protected function migrateAttributes()
$destinationRecord->setValue('attribute_id', null);
$destinationRecord->setValue(
'entity_type_id',
- $this->getEntityTypeIdMappedByCode($destinationRecord->getValue('entity_type_id'), false)
+ $this->mapEntityTypeIdsDestOldNew[$destinationRecord->getValue('entity_type_id')]
);
$recordsToSave->addRecord($destinationRecord);
}
$this->destination->clearDocument($destinationDocument->getName());
$this->saveRecords($destinationDocument, $recordsToSave);
- $this->loadNewAttributes();
+ $this->createMapAttributeIds();
}
/**
@@ -367,15 +454,17 @@ protected function migrateEntityAttributes()
}
foreach ($this->helper->getDestinationRecords('eav_entity_attribute') as $record) {
- if (!isset($this->destAttributeOldNewMap[$record['attribute_id']])
- || !isset($this->destAttributeSetsOldNewMap[$record['attribute_set_id']])
- || !isset($this->destAttributeGroupsOldNewMap[$record['attribute_group_id']])
+ if (!isset($this->mapAttributeIdsDestOldNew[$record['attribute_id']])
+ || !isset($this->mapAttributeSetIdsDestOldNew[$record['attribute_set_id']])
+ || !isset($this->mapAttributeGroupIdsDestOldNew[$record['attribute_group_id']])
+ || !isset($this->mapEntityTypeIdsDestOldNew[$record['entity_type_id']])
) {
continue;
}
- $record['attribute_id'] = $this->destAttributeOldNewMap[$record['attribute_id']];
- $record['attribute_set_id'] = $this->destAttributeSetsOldNewMap[$record['attribute_set_id']];
- $record['attribute_group_id'] = $this->destAttributeGroupsOldNewMap[$record['attribute_group_id']];
+ $record['attribute_id'] = $this->mapAttributeIdsDestOldNew[$record['attribute_id']];
+ $record['attribute_set_id'] = $this->mapAttributeSetIdsDestOldNew[$record['attribute_set_id']];
+ $record['attribute_group_id'] = $this->mapAttributeGroupIdsDestOldNew[$record['attribute_group_id']];
+ $record['entity_type_id'] = $this->mapEntityTypeIdsDestOldNew[$record['entity_type_id']];
$record['entity_attribute_id'] = null;
$destinationRecord = $this->factory->create(['document' => $destinationDocument, 'data' => $record]);
@@ -383,7 +472,7 @@ protected function migrateEntityAttributes()
}
$recordsToSave = $this->processDesignEntityAttributes($recordsToSave);
- $recordsToSave = $this->moveAttributes($recordsToSave);
+ $recordsToSave = $this->moveProductAttributes($recordsToSave);
$this->destination->clearDocument($destinationDocument->getName());
$this->saveRecords($destinationDocument, $recordsToSave);
@@ -395,11 +484,11 @@ protected function migrateEntityAttributes()
* @param Record\Collection $recordsToSave
* @return Record\Collection
*/
- private function moveAttributes($recordsToSave)
+ private function moveProductAttributes($recordsToSave)
{
- $this->moveAttributeToGroup($recordsToSave, 'price', 'product-details');
- $this->moveAttributeToGroup($recordsToSave, 'shipment_type', 'bundle-items');
- $this->addAttributeToGroup($recordsToSave, 'quantity_and_stock_status', 'product-details');
+ $this->moveProductAttributeToGroup($recordsToSave, 'price', 'product-details');
+ $this->moveProductAttributeToGroup($recordsToSave, 'shipment_type', 'bundle-items');
+ $this->addProductAttributeToGroup($recordsToSave, 'quantity_and_stock_status', 'product-details');
return $recordsToSave;
}
@@ -411,8 +500,10 @@ private function moveAttributes($recordsToSave)
* @param string $attributeGroupCode
* @return Record\Collection
*/
- private function moveAttributeToGroup($recordsToSave, $attributeCode, $attributeGroupCode)
+ private function moveProductAttributeToGroup($recordsToSave, $attributeCode, $attributeGroupCode)
{
+ $productEntityType
+ = $this->helper->getSourceRecords('eav_entity_type', ['entity_type_code'])['catalog_product'];
$attributes = $this->helper->getDestinationRecords('eav_attribute', ['attribute_id']);
$attributeGroups = $this->helper->getDestinationRecords('eav_attribute_group', ['attribute_group_id']);
$attributeSetGroups = [];
@@ -424,7 +515,10 @@ private function moveAttributeToGroup($recordsToSave, $attributeCode, $attribute
}
foreach ($recordsToSave as $record) {
$attributeId = $record->getValue('attribute_id');
- if (!isset($attributes[$attributeId])) {
+ $entityTypeId = $record->getValue('entity_type_id');
+ if (!isset($attributes[$attributeId])
+ || $entityTypeId != $productEntityType['entity_type_id']
+ ) {
continue;
}
if ($attributes[$attributeId]['attribute_code'] == $attributeCode) {
@@ -445,8 +539,10 @@ private function moveAttributeToGroup($recordsToSave, $attributeCode, $attribute
* @param string $attributeGroupCode
* @return Record\Collection
*/
- private function addAttributeToGroup($recordsToSave, $attributeCode, $attributeGroupCode)
+ private function addProductAttributeToGroup($recordsToSave, $attributeCode, $attributeGroupCode)
{
+ $productEntityType
+ = $this->helper->getSourceRecords('eav_entity_type', ['entity_type_code'])['catalog_product'];
$attributes = $this->helper->getDestinationRecords('eav_attribute', ['attribute_id']);
$attributeGroups = $this->helper->getDestinationRecords('eav_attribute_group', ['attribute_group_id']);
$attributeSetGroups = [];
@@ -459,7 +555,10 @@ private function addAttributeToGroup($recordsToSave, $attributeCode, $attributeG
$attribute = null;
foreach ($recordsToSave as $record) {
$attributeId = $record->getValue('attribute_id');
- if (!isset($attributes[$attributeId])) {
+ $entityTypeId = $record->getValue('entity_type_id');
+ if (!isset($attributes[$attributeId])
+ || $entityTypeId != $productEntityType['entity_type_id']
+ ) {
continue;
}
if ($attributes[$attributeId]['attribute_code'] == $attributeCode) {
@@ -498,19 +597,7 @@ private function addAttributeToGroup($recordsToSave, $attributeCode, $attributeG
*/
private function processDesignEntityAttributes($recordsToSave)
{
- $entityTypeIdCatalogProduct = 0;
- foreach ($this->helper->getDestinationRecords('eav_entity_type') as $record) {
- if ('catalog_product' == $record['entity_type_code']) {
- $entityTypeIdCatalogProduct = $record['entity_type_id'];
- break;
- }
- }
- $entityTypeIdCatalogProductMapped = $this->getEntityTypeIdMappedByCode($entityTypeIdCatalogProduct, false);
- $data = $this->helper->getDesignAttributeAndGroupsData(
- $entityTypeIdCatalogProduct,
- $entityTypeIdCatalogProductMapped
- );
-
+ $data = $this->helper->getDesignAttributeAndGroupsData();
$entityAttributeDocument = $this->destination->getDocument(
$this->map->getDocumentMap('eav_entity_attribute', MapInterface::TYPE_SOURCE)
);
@@ -530,7 +617,7 @@ private function processDesignEntityAttributes($recordsToSave)
if (isset($data['customDesignAttributeId']) && $data['customDesignAttributeId']) {
$dataRecord = [
'entity_attribute_id' => null,
- 'entity_type_id' => $entityTypeIdCatalogProductMapped,
+ 'entity_type_id' => $data['entityTypeIdCatalogProduct'],
'attribute_set_id' => $group['attribute_set_id'],
'attribute_group_id' => $group['attribute_group_id'],
'attribute_id' => $data['customDesignAttributeId'],
@@ -547,7 +634,7 @@ private function processDesignEntityAttributes($recordsToSave)
if (isset($data['customLayoutAttributeId']) && $data['customLayoutAttributeId']) {
$dataRecord = [
'entity_attribute_id' => null,
- 'entity_type_id' => $entityTypeIdCatalogProductMapped,
+ 'entity_type_id' => $data['entityTypeIdCatalogProduct'],
'attribute_set_id' => $group['attribute_set_id'],
'attribute_group_id' => $group['attribute_group_id'],
'attribute_id' => $data['customLayoutAttributeId'],
@@ -566,75 +653,53 @@ private function processDesignEntityAttributes($recordsToSave)
}
/**
- * Migrate EAV tables which in result must have all unique records from both source and destination documents
+ * Migrate tables extended from eav_attribute
+ *
* @return void
*/
- protected function migrateMappedTables()
+ protected function migrateAttributesExtended()
{
- $documents = $this->readerGroups->getGroup('mapped_documents');
-
- foreach ($documents as $documentName => $mappingFields) {
+ $documents = $this->readerGroups->getGroup('documents_attribute_extended');
+ foreach ($documents as $documentName => $mappingField) {
$this->progress->advance();
$sourceDocument = $this->source->getDocument($documentName);
$destinationDocument = $this->destination->getDocument(
$this->map->getDocumentMap($documentName, MapInterface::TYPE_SOURCE)
);
$this->destination->backupDocument($destinationDocument->getName());
- $mappingFields = explode(',', $mappingFields);
- $destinationRecords = $this->helper->getDestinationRecords($documentName, $mappingFields);
+ $destinationRecords = $this->helper->getDestinationRecords($documentName, [$mappingField]);
$recordsToSave = $destinationDocument->getRecords();
foreach ($this->helper->getSourceRecords($documentName) as $recordData) {
/** @var Record $sourceRecord */
$sourceRecord = $this->factory->create(['document' => $sourceDocument, 'data' => $recordData]);
/** @var Record $destinationRecord */
$destinationRecord = $this->factory->create(['document' => $destinationDocument]);
-
- $mappingValue = $this->getMappingValue($sourceRecord, $mappingFields);
- if (isset($destinationRecords[$mappingValue])) {
- $destinationRecordData = $destinationRecords[$mappingValue];
- unset($destinationRecords[$mappingValue]);
+ $mappedId = isset($this->mapAttributeIdsSourceDest[$sourceRecord->getValue($mappingField)])
+ ? $this->mapAttributeIdsSourceDest[$sourceRecord->getValue($mappingField)]
+ : null;
+ if ($mappedId !== null && isset($destinationRecords[$mappedId])) {
+ $destinationRecordData = $destinationRecords[$mappedId];
+ unset($destinationRecords[$mappedId]);
} else {
$destinationRecordData = array_fill_keys($destinationRecord->getFields(), null);
}
$destinationRecord->setData($destinationRecordData);
-
$this->helper->getRecordTransformer($sourceDocument, $destinationDocument)
->transform($sourceRecord, $destinationRecord);
-
- if ($documentName == 'eav_entity_type') {
- $oldAttributeSetValue = $destinationRecord->getValue('default_attribute_set_id');
- if (isset($this->destAttributeSetsOldNewMap[$oldAttributeSetValue])) {
- $destinationRecord->setValue(
- 'default_attribute_set_id',
- $this->destAttributeSetsOldNewMap[$oldAttributeSetValue]
- );
- }
- }
-
$recordsToSave->addRecord($destinationRecord);
}
$this->destination->clearDocument($destinationDocument->getName());
$this->saveRecords($destinationDocument, $recordsToSave);
$recordsToSave = $destinationDocument->getRecords();
- if ($mappingFields) {
- foreach ($destinationRecords as $record) {
- $destinationRecord = $this->factory->create([
- 'document' => $destinationDocument,
- 'data' => $record
- ]);
- if (isset($record['attribute_id'])
- && isset($this->destAttributeOldNewMap[$record['attribute_id']])
- ) {
- $destinationRecord->setValue(
- 'attribute_id',
- $this->destAttributeOldNewMap[$record['attribute_id']]
- );
- }
- $recordsToSave->addRecord($destinationRecord);
- }
+ foreach ($destinationRecords as $record) {
+ $record['attribute_id'] = $this->mapAttributeIdsDestOldNew[$record['attribute_id']];
+ $destinationRecord = $this->factory->create([
+ 'document' => $destinationDocument,
+ 'data' => $record
+ ]);
+ $recordsToSave->addRecord($destinationRecord);
}
-
$this->saveRecords($destinationDocument, $recordsToSave);
}
}
@@ -650,127 +715,94 @@ protected function saveRecords(Document $document, Record\Collection $recordsToS
}
/**
- * @param Record $sourceRecord
- * @param array $keyFields
- * @return string
+ * Create mapping for entity type ids
+ *
+ * @return void
*/
- protected function getMappingValue(Record $sourceRecord, $keyFields)
+ protected function createMapEntityTypeIds()
{
- $value = [];
- foreach ($keyFields as $field) {
- switch ($field) {
- case 'attribute_id':
- $value[] = $this->getDestinationAttributeId($sourceRecord->getValue($field));
- break;
- default:
- $value[] = $sourceRecord->getValue($field);
- break;
+ $entityTypesMigrated = $this->helper->getDestinationRecords(
+ 'eav_entity_type',
+ ['entity_type_code']
+ );
+ foreach ($this->initialData->getEntityTypes('dest') as $entityTypeIdOld => $recordOld) {
+ $entityTypeMigrated = $entityTypesMigrated[$recordOld['entity_type_code']];
+ $this->mapEntityTypeIdsDestOldNew[$entityTypeIdOld] = $entityTypeMigrated['entity_type_id'];
+ }
+ foreach ($this->initialData->getEntityTypes('source') as $entityTypeIdSource => $recordSource) {
+ foreach ($this->initialData->getEntityTypes('dest') as $entityTypeIdDest => $recordDest) {
+ if ($recordSource['entity_type_code'] == $recordDest['entity_type_code']) {
+ $this->mapEntityTypeIdsSourceDest[$entityTypeIdSource] = $entityTypeIdDest;
+ }
}
}
- return implode('-', $value);
}
/**
- * Load migrated attribute sets data
+ * Create mapping for attribute set ids
+ *
* @return void
*/
- protected function loadNewAttributeSets()
+ protected function createMapAttributeSetIds()
{
$this->newAttributeSets = $this->helper->getDestinationRecords(
'eav_attribute_set',
['entity_type_id', 'attribute_set_name']
);
foreach ($this->initialData->getAttributeSets('dest') as $attributeSetId => $record) {
- $newAttributeSet = $this->newAttributeSets[$record['entity_type_id'] . '-' . $record['attribute_set_name']];
- $this->destAttributeSetsOldNewMap[$attributeSetId] = $newAttributeSet['attribute_set_id'];
+ $entityTypeId = $this->mapEntityTypeIdsDestOldNew[$record['entity_type_id']];
+ $newAttributeSet = $this->newAttributeSets[$entityTypeId . '-' . $record['attribute_set_name']];
+ $this->mapAttributeSetIdsDestOldNew[$attributeSetId] = $newAttributeSet['attribute_set_id'];
}
}
/**
- * Load migrated attribute groups data
+ * Create mapping for attribute group ids
+ *
* @return void
*/
- protected function loadNewAttributeGroups()
+ protected function createMapAttributeGroupIds()
{
- $this->newAttributeGroups = $this->helper->getDestinationRecords(
+ $newAttributeGroups = $this->helper->getDestinationRecords(
'eav_attribute_group',
['attribute_set_id', 'attribute_group_name']
);
foreach ($this->initialData->getAttributeGroups('dest') as $record) {
- $newKey = $this->destAttributeSetsOldNewMap[$record['attribute_set_id']] . '-'
+ $newKey = $this->mapAttributeSetIdsDestOldNew[$record['attribute_set_id']] . '-'
. $record['attribute_group_name'];
- $newAttributeGroup = $this->newAttributeGroups[$newKey];
- $this->destAttributeGroupsOldNewMap[$record['attribute_group_id']] =
+ $newAttributeGroup = $newAttributeGroups[$newKey];
+ $this->mapAttributeGroupIdsDestOldNew[$record['attribute_group_id']] =
$newAttributeGroup['attribute_group_id'];
}
}
/**
- * Load migrated attributes data
- * @return array
+ * Create mapping for attribute ids
+ *
+ * @return void
*/
- protected function loadNewAttributes()
+ protected function createMapAttributeIds()
{
- $this->newAttributes = $this->helper->getDestinationRecords(
+ $newAttributes = $this->helper->getDestinationRecords(
'eav_attribute',
['entity_type_id', 'attribute_code']
);
- foreach ($this->initialData->getAttributes('dest') as $key => $attributeData) {
- list($entityTypeId, $attributeCode) = explode('-', $key);
- $key = $this->getEntityTypeIdMappedByCode($entityTypeId, false) . '-' . $attributeCode;
- $this->destAttributeOldNewMap[$attributeData['attribute_id']] = $this->newAttributes[$key]['attribute_id'];
+ foreach ($this->initialData->getAttributes('dest') as $keyOld => $attributeOld) {
+ list($entityTypeId, $attributeCodeDest) = explode('-', $keyOld);
+ $keyMapped = $this->mapEntityTypeIdsDestOldNew[$entityTypeId] . '-' . $attributeCodeDest;
+ $this->mapAttributeIdsDestOldNew[$attributeOld['attribute_id']] =
+ $newAttributes[$keyMapped]['attribute_id'];
}
-
- return $this->newAttributes;
- }
-
- /**
- * Returns destination entity type id for correspondent source entity type id and vise versa
- * Linking between two values is performed using entity_type_code
- * @param int|string $initialEntityTypeId
- * @param bool $returnDestId
- * @return mixed
- */
- protected function getEntityTypeIdMappedByCode($initialEntityTypeId, $returnDestId = true)
- {
- $id = $initialEntityTypeId;
- $entityTypeIdsFrom =
- $this->initialData->getEntityTypesWithKeyField($returnDestId ? 'source' : 'dest', 'entity_type_id');
- $entityTypeCodesTo =
- $this->initialData->getEntityTypesWithKeyField($returnDestId ? 'dest' : 'source', 'entity_type_code');
-
- if (isset($entityTypeIdsFrom[$initialEntityTypeId])) {
- $entityTypeCode = $entityTypeIdsFrom[$initialEntityTypeId]['entity_type_code'];
- if (isset($entityTypeCodesTo[$entityTypeCode])) {
- $id = $entityTypeCodesTo[$entityTypeCode]['entity_type_id'];
+ foreach ($this->initialData->getAttributes('source') as $idSource => $attributeSource) {
+ foreach ($this->initialData->getAttributes('dest') as $keyDest => $attributeDest) {
+ list($entityTypeIdDest, $attributeCodeDest) = explode('-', $keyDest);
+ $keyDestMapped = $this->mapEntityTypeIdsDestOldNew[$entityTypeIdDest] . '-' . $attributeCodeDest;
+ $keySource = $attributeSource['entity_type_id'] . '-' . $attributeSource['attribute_code'];
+ if ($keySource == $keyDestMapped) {
+ $this->mapAttributeIdsSourceDest[$idSource] = $attributeDest['attribute_id'];
+ }
}
}
-
- return $id;
- }
-
- /**
- * @param int $sourceAttributeId
- * @return mixed
- */
- protected function getDestinationAttributeId($sourceAttributeId)
- {
- $id = null;
- $key = null;
- if (isset($this->initialData->getAttributes('source')[$sourceAttributeId])) {
- $entityTypeId = $this->getEntityTypeIdMappedByCode(
- $this->initialData->getAttributes('source')[$sourceAttributeId]['entity_type_id'],
- true
- );
- $key = $entityTypeId . '-'
- . $this->initialData->getAttributes('source')[$sourceAttributeId]['attribute_code'];
- }
-
- if ($key && isset($this->initialData->getAttributes('dest')[$key])) {
- $id = $this->initialData->getAttributes('dest')[$key]['attribute_id'];
- }
-
- return $id;
}
/**
@@ -796,22 +828,4 @@ public function rollback()
}
}
}
-
- /**
- * Remove ignored attributes from source records
- *
- * @param array $sourceRecords
- * @param array $attributeToClear
- * @return array
- */
- protected function clearIgnoredAttributes($sourceRecords, $attributeToClear)
- {
- foreach ($sourceRecords as $attrNum => $sourceAttribute) {
- if ($sourceAttribute['attribute_code'] == $attributeToClear) {
- unset($sourceRecords[$attrNum]);
- }
- }
- return $sourceRecords;
- }
- // @codeCoverageIgnoreEnd
}
diff --git a/src/Migration/Step/Eav/Helper.php b/src/Migration/Step/Eav/Helper.php
index 8743b113a..81c83bb34 100644
--- a/src/Migration/Step/Eav/Helper.php
+++ b/src/Migration/Step/Eav/Helper.php
@@ -40,10 +40,15 @@ class Helper
*/
protected $readerGroups;
+ /**
+ * @var \Migration\Reader\Groups
+ */
+ protected $readerAttributes;
+
/**
* @var \Migration\ResourceModel\Record[]
*/
- protected $addedGroups ;
+ protected $addedGroups;
/**
* @param MapFactory $mapFactory
@@ -64,6 +69,7 @@ public function __construct(
$this->destination = $destination;
$this->factory = $factory;
$this->readerGroups = $groupsFactory->create('eav_document_groups_file');
+ $this->readerAttributes = $groupsFactory->create('eav_attribute_groups_file');
}
/**
@@ -181,18 +187,18 @@ public function setAddedGroups(array $addedGroups)
}
/**
- * @param int|string $entityTypeIdCatalogProduct
- * @param int|string $entityTypeIdCatalogProductMapped
* @return array
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
- public function getDesignAttributeAndGroupsData($entityTypeIdCatalogProduct, $entityTypeIdCatalogProductMapped)
+ public function getDesignAttributeAndGroupsData()
{
$scheduleGroupsMigrated = [];
$catalogProductSetIdsMigrated = [];
$catalogProductSetIdDefault = null;
$customLayoutAttributeId = null;
$customDesignAttributeId = null;
+ $entityTypeIdCatalogProduct = $this->getDestinationRecords('eav_entity_type', ['entity_type_code'])
+ ['catalog_product']['entity_type_id'];
foreach ($this->getDestinationRecords('eav_attribute_set') as $record) {
if ($entityTypeIdCatalogProduct == $record['entity_type_id']) {
@@ -211,7 +217,7 @@ public function getDesignAttributeAndGroupsData($entityTypeIdCatalogProduct, $en
}
}
foreach ($this->getDestinationRecords('eav_attribute') as $record) {
- if ($record['entity_type_id'] == $entityTypeIdCatalogProductMapped) {
+ if ($record['entity_type_id'] == $entityTypeIdCatalogProduct) {
switch ($record['attribute_code']) {
case 'custom_layout':
$customLayoutAttributeId = $record['attribute_id'];
@@ -231,4 +237,24 @@ public function getDesignAttributeAndGroupsData($entityTypeIdCatalogProduct, $en
'entityTypeIdCatalogProduct' => $entityTypeIdCatalogProduct
];
}
+
+ /**
+ * Remove ignored attributes from source records
+ *
+ * @param array $sourceRecords
+ * @return array
+ */
+ public function clearIgnoredAttributes($sourceRecords)
+ {
+ $ignoredAttributes = array_keys($this->readerAttributes->getGroup('ignore'));
+ foreach ($sourceRecords as $attrNum => $sourceAttribute) {
+ if (
+ isset($sourceAttribute['attribute_code'])
+ && (in_array($sourceAttribute['attribute_code'], $ignoredAttributes))
+ ) {
+ unset($sourceRecords[$attrNum]);
+ }
+ }
+ return $sourceRecords;
+ }
}
diff --git a/src/Migration/Step/Eav/InitialData.php b/src/Migration/Step/Eav/InitialData.php
index e3e933ccd..c16f8ce72 100644
--- a/src/Migration/Step/Eav/InitialData.php
+++ b/src/Migration/Step/Eav/InitialData.php
@@ -91,16 +91,8 @@ public function init()
protected function initEntityTypes()
{
if ($this->entityTypes === null) {
- $sourceRecords = $this->helper->getSourceRecords('eav_entity_type');
- foreach ($sourceRecords as $record) {
- $this->entityTypes['source']['entity_type_id'][$record['entity_type_id']] = $record;
- $this->entityTypes['source']['entity_type_code'][$record['entity_type_code']] = $record;
- }
- $destinationRecords = $this->helper->getDestinationRecords('eav_entity_type');
- foreach ($destinationRecords as $record) {
- $this->entityTypes['dest']['entity_type_id'][$record['entity_type_id']] = $record;
- $this->entityTypes['dest']['entity_type_code'][$record['entity_type_code']] = $record;
- }
+ $this->entityTypes['source'] = $this->helper->getSourceRecords('eav_entity_type', ['entity_type_id']);
+ $this->entityTypes['dest'] = $this->helper->getDestinationRecords('eav_entity_type', ['entity_type_id']);
}
}
@@ -156,12 +148,11 @@ protected function initAttributeGroups()
/**
* @codeCoverageIgnore
* @param string $type
- * @param string $keyField
* @return array
*/
- public function getEntityTypesWithKeyField($type, $keyField)
+ public function getEntityTypes($type)
{
- return $this->entityTypes[$type][$keyField];
+ return $this->entityTypes[$type];
}
/**
diff --git a/src/Migration/Step/Eav/Integrity.php b/src/Migration/Step/Eav/Integrity.php
index cce9a6fa0..f04b74961 100644
--- a/src/Migration/Step/Eav/Integrity.php
+++ b/src/Migration/Step/Eav/Integrity.php
@@ -11,6 +11,7 @@
use Migration\Reader\MapFactory;
use Migration\App\ProgressBar;
use Migration\ResourceModel;
+use Migration\Step\Eav\Integrity\AttributeGroupNames as AttributeGroupNamesIntegrity;
/**
* Class Integrity
@@ -20,7 +21,12 @@ class Integrity extends \Migration\App\Step\AbstractIntegrity
/**
* @var \Migration\Reader\Groups
*/
- protected $groups;
+ private $groups;
+
+ /**
+ * @var AttributeGroupNamesIntegrity
+ */
+ private $attributeGroupNamesIntegrity;
/**
* @param ProgressBar\LogLevelProcessor $progress
@@ -29,6 +35,7 @@ class Integrity extends \Migration\App\Step\AbstractIntegrity
* @param ResourceModel\Destination $destination
* @param MapFactory $mapFactory
* @param GroupsFactory $groupsFactory
+ * @param AttributeGroupNamesIntegrity $attributeGroupNamesIntegrity
* @param string $mapConfigOption
*/
public function __construct(
@@ -38,9 +45,11 @@ public function __construct(
ResourceModel\Destination $destination,
MapFactory $mapFactory,
GroupsFactory $groupsFactory,
+ AttributeGroupNamesIntegrity $attributeGroupNamesIntegrity,
$mapConfigOption = 'eav_map_file'
) {
$this->groups = $groupsFactory->create('eav_document_groups_file');
+ $this->attributeGroupNamesIntegrity = $attributeGroupNamesIntegrity;
parent::__construct($progress, $logger, $source, $destination, $mapFactory, $mapConfigOption);
}
@@ -57,7 +66,7 @@ public function perform()
$destinationDocumentName = $this->map->getDocumentMap($sourceDocumentName, MapInterface::TYPE_SOURCE);
$this->check([$destinationDocumentName], MapInterface::TYPE_DEST);
}
-
+ $this->incompatibleDocumentFieldsData = $this->attributeGroupNamesIntegrity->checkAttributeGroupNames();
$this->progress->finish();
return $this->checkForErrors();
}
diff --git a/src/Migration/Step/Eav/Integrity/AttributeGroupNames.php b/src/Migration/Step/Eav/Integrity/AttributeGroupNames.php
new file mode 100644
index 000000000..2ac6ffab6
--- /dev/null
+++ b/src/Migration/Step/Eav/Integrity/AttributeGroupNames.php
@@ -0,0 +1,101 @@
+helper = $helper;
+ $this->groupNameToCodeMap = $groupNameToCodeMap;
+ }
+
+ /**
+ * Check product attribute sets contain all required attribute group names
+ *
+ * @return bool
+ */
+ public function checkAttributeGroupNames()
+ {
+ $attributeGroups = $this->helper->getSourceRecords($this->attributeGroupDocument, ['attribute_group_id']);
+ $entityTypeIdCatalogProduct = $this->helper->getSourceRecords('eav_entity_type', ['entity_type_code'])
+ ['catalog_product']['entity_type_id'];
+ $attributeSetsOfCatalogProduct = [];
+ $attributeSets = $this->helper->getSourceRecords('eav_attribute_set', ['attribute_set_id']);
+ foreach ($attributeSets as $attributeSet) {
+ if ($attributeSet['entity_type_id'] == $entityTypeIdCatalogProduct) {
+ $attributeSetsOfCatalogProduct[$attributeSet['attribute_set_id']] =
+ $attributeSet['attribute_set_name'];
+ }
+ }
+ $attributeGroupsOfCatalogProduct = [];
+ foreach ($attributeGroups as $group) {
+ if (in_array($group['attribute_set_id'], array_keys($attributeSetsOfCatalogProduct))) {
+ $attributeGroupsOfCatalogProduct[$group['attribute_set_id']][] = $group[$this->attributeGroupFieldName];
+ }
+ }
+ return $this->checkForErrors($attributeGroupsOfCatalogProduct, $attributeSetsOfCatalogProduct);
+ }
+
+ /**
+ * @param array $attributeGroupsOfCatalogProduct
+ * @param array $attributeSetsOfCatalogProduct
+ * @return array
+ */
+ protected function checkForErrors(array $attributeGroupsOfCatalogProduct, array $attributeSetsOfCatalogProduct)
+ {
+ $incompatibleDocumentFieldsData = [];
+ $groupNamesToValidate = array_keys($this->groupNameToCodeMap->getMap());
+ foreach ($attributeGroupsOfCatalogProduct as $attributeSetId => $groupNames) {
+ if (!empty(array_diff($groupNamesToValidate, $groupNames))) {
+ $error = 'The product attribute set "%s" does not contain all required attribute group names "%s"';
+ $error = sprintf(
+ $error,
+ $attributeSetsOfCatalogProduct[$attributeSetId],
+ implode(', ', $groupNamesToValidate)
+ );
+ $errorDetails['document'] = $this->attributeGroupDocument;
+ $errorDetails['field'] = $this->attributeGroupFieldName;
+ $errorDetails['error'] = $error;
+ $incompatibleDocumentFieldsData[MapInterface::TYPE_SOURCE][] = $errorDetails;
+ }
+ }
+ return $incompatibleDocumentFieldsData;
+ }
+}
diff --git a/src/Migration/Step/Eav/Volume.php b/src/Migration/Step/Eav/Volume.php
index ba1ba5a0f..d77edadd0 100644
--- a/src/Migration/Step/Eav/Volume.php
+++ b/src/Migration/Step/Eav/Volume.php
@@ -178,7 +178,7 @@ protected function validateCustomConditions(array $attribute, array $conditions)
*/
protected function checkAttributesMismatch($attribute)
{
- $sourceAttributes = $this->initialData->getAttributes('source');
+ $sourceAttributes = $this->helper->clearIgnoredAttributes($this->initialData->getAttributes('source'));
if (isset($sourceAttributes[$attribute['attribute_id']])
&& ($sourceAttributes[$attribute['attribute_id']]['attribute_code'] != $attribute['attribute_code'])
diff --git a/src/Migration/Step/Log/Data.php b/src/Migration/Step/Log/Data.php
index 876e09e07..91c1c0f2e 100644
--- a/src/Migration/Step/Log/Data.php
+++ b/src/Migration/Step/Log/Data.php
@@ -104,7 +104,7 @@ public function __construct(
*/
public function perform()
{
- $this->progress->start($this->getIterationsCount(), LogManager::LOG_LEVEL_INFO);
+ $this->progress->start($this->getBulksCount(), LogManager::LOG_LEVEL_INFO);
$sourceDocuments = array_keys($this->readerGroups->getGroup('source_documents'));
foreach ($sourceDocuments as $sourceDocName) {
$sourceDocument = $this->source->getDocument($sourceDocName);
@@ -126,7 +126,6 @@ public function perform()
$pageNumber++;
$destinationRecords = $destDocument->getRecords();
foreach ($bulk as $recordData) {
- $this->progress->advance(LogManager::LOG_LEVEL_INFO);
$this->progress->advance(LogManager::LOG_LEVEL_DEBUG);
/** @var Record $destRecord */
$destRecord = $this->recordFactory->create([
@@ -137,6 +136,7 @@ public function perform()
}
$this->destination->saveRecords($destinationName, $destinationRecords);
}
+ $this->progress->advance(LogManager::LOG_LEVEL_INFO);
$this->progress->finish(LogManager::LOG_LEVEL_DEBUG);
}
$this->clearLog(array_keys($this->readerGroups->getGroup('destination_documents_to_clear')));
@@ -203,11 +203,11 @@ protected function clearLog($documents)
*
* @return int
*/
- protected function getIterationsCount()
+ protected function getBulksCount()
{
$iterations = 0;
foreach (array_keys($this->readerGroups->getGroup('source_documents')) as $document) {
- $iterations += $this->source->getRecordsCount($document);
+ $iterations += ceil($this->source->getRecordsCount($document) / $this->source->getPageSize($document));
}
return count($this->readerGroups->getGroup('destination_documents_to_clear'))
diff --git a/src/Migration/Step/Map/Data.php b/src/Migration/Step/Map/Data.php
index 91b7810ba..45de41826 100644
--- a/src/Migration/Step/Map/Data.php
+++ b/src/Migration/Step/Map/Data.php
@@ -249,7 +249,7 @@ protected function isCopiedDirectly(Document $sourceDocument, Document $destinat
);
} catch (\Exception $e) {
$this->copyDirectly = false;
- $this->logger->error(
+ $this->logger->warning(
'Document ' . $sourceDocument->getName() . ' can not be copied directly because of error: '
. $e->getMessage()
);
diff --git a/src/Migration/Step/SalesIncrement/Helper.php b/src/Migration/Step/SalesIncrement/Helper.php
index 98cb4c01e..4054058a0 100644
--- a/src/Migration/Step/SalesIncrement/Helper.php
+++ b/src/Migration/Step/SalesIncrement/Helper.php
@@ -7,6 +7,7 @@
use Migration\ResourceModel\Source;
use Migration\ResourceModel\Destination;
+use Migration\ResourceModel\Adapter\Mysql;
/**
* Class Helper
@@ -69,27 +70,22 @@ class Helper
*/
protected $entityTypeTablesMap = [
[
- 'entity_type_id' => 5,
'entity_type_code' => 'order',
'entity_type_table' => 'sequence_order',
'column' => 'sequence_value'
], [
- 'entity_type_id' => 6,
'entity_type_code' => 'invoice',
'entity_type_table' => 'sequence_invoice',
'column' => 'sequence_value'
], [
- 'entity_type_id' => 7,
'entity_type_code' => 'creditmemo',
'entity_type_table' => 'sequence_creditmemo',
'column' => 'sequence_value'
], [
- 'entity_type_id' => 8,
'entity_type_code' => 'shipment',
'entity_type_table' => 'sequence_shipment',
'column' => 'sequence_value'
], [
- 'entity_type_id' => 9,
'entity_type_code' => 'rma_item',
'entity_type_table' => 'sequence_rma_item',
'column' => 'sequence_value'
@@ -146,6 +142,12 @@ public function getStoreIds()
*/
public function getEntityTypeTablesMap()
{
+ $entityIds = $this->getEntityTypeIdByCode(array_column($this->entityTypeTablesMap, 'entity_type_code'));
+ foreach ($this->entityTypeTablesMap as &$entityTypeTable) {
+ $entityTypeTable['entity_type_id'] = isset($entityIds[$entityTypeTable['entity_type_code']])
+ ? $entityIds[$entityTypeTable['entity_type_code']]
+ : null;
+ }
return $this->entityTypeTablesMap;
}
@@ -193,4 +195,26 @@ public function getTableName($table, $storeId = false)
? $this->destination->addDocumentPrefix($table) . '_' . $storeId
: $this->destination->addDocumentPrefix($table);
}
+
+ /**
+ * @param array $entityTypeCodes
+ * @return array
+ */
+ protected function getEntityTypeIdByCode($entityTypeCodes)
+ {
+ /** @var Mysql $adapter */
+ $adapter = $this->destination->getAdapter();
+ $query = $adapter->getSelect()
+ ->from(
+ ['et' => $this->destination->addDocumentPrefix('eav_entity_type')],
+ ['entity_type_id', 'entity_type_code']
+ )
+ ->where('et.entity_type_code IN (?)', $entityTypeCodes);
+ $entityTypeIds = [];
+ foreach ($query->getAdapter()->fetchAll($query) as $record) {
+ $entityTypeIds[$record['entity_type_code']] = $record['entity_type_id'];
+ }
+ return $entityTypeIds;
+
+ }
}
diff --git a/src/Migration/Step/UrlRewrite/Version191to2000.php b/src/Migration/Step/UrlRewrite/Version191to2000.php
index 5b874bd2f..d553d3fe9 100644
--- a/src/Migration/Step/UrlRewrite/Version191to2000.php
+++ b/src/Migration/Step/UrlRewrite/Version191to2000.php
@@ -183,7 +183,9 @@ protected function integrity()
*/
protected function data()
{
- $this->progress->start($this->source->getRecordsCount(self::SOURCE) + $this->countCmsPageRewrites());
+ $this->progress->start(
+ ceil($this->source->getRecordsCount(self::SOURCE) / $this->source->getPageSize(self::SOURCE))
+ );
$sourceDocument = $this->source->getDocument(self::SOURCE);
$destDocument = $this->destination->getDocument(self::DESTINATION);
@@ -198,7 +200,6 @@ protected function data()
$destinationRecords = $destDocument->getRecords();
$destProductCategoryRecords = $destProductCategory->getRecords();
foreach ($bulk as $recordData) {
- $this->progress->advance();
/** @var Record $record */
$record = $this->recordFactory->create(['document' => $sourceDocument, 'data' => $recordData]);
/** @var Record $destRecord */
@@ -207,6 +208,7 @@ protected function data()
if ($record->getValue('is_system')
&& $record->getValue('product_id')
&& $record->getValue('category_id')
+ && $record->getValue('request_path') !== null
) {
$destProductCategoryRecord = $this->recordFactory->create(['document' => $destProductCategory]);
$destProductCategoryRecord->setValue('url_rewrite_id', $record->getValue('url_rewrite_id'));
@@ -217,11 +219,13 @@ protected function data()
$destinationRecords->addRecord($destRecord);
}
+
+ $this->progress->advance();
$this->destination->saveRecords(self::DESTINATION, $destinationRecords);
$this->destination->saveRecords(self::DESTINATION_PRODUCT_CATEGORY, $destProductCategoryRecords);
}
- $this->collectCmsPageRewrites();
+ $this->saveCmsPageRewrites();
$this->progress->finish();
return true;
}
@@ -247,8 +251,8 @@ protected function volume()
{
$result = true;
$this->progress->start(1);
- $result &= $this->source->getRecordsCount(self::SOURCE) + $this->countCmsPageRewrites(true) ==
- $this->destination->getRecordsCount(self::DESTINATION);
+ $result &= $this->source->getRecordsCount(self::SOURCE) + $this->countCmsPageRewrites() ==
+ ($this->destination->getRecordsCount(self::DESTINATION));
if (!$result) {
$this->logger->error('Mismatch of entities in the document: url_rewrite');
}
@@ -257,6 +261,26 @@ protected function volume()
return (bool)$result;
}
+ /**
+ * Get request_paths from core_url_rewrite that matches cms_page.identifier
+ *
+ * @return \Magento\Framework\Db\Select
+ */
+ protected function getUrlRewriteRequestPathsSelect()
+ {
+ $select = $this->source->getAdapter()->getSelect();
+ $select->from(
+ ['cur' => $this->source->addDocumentPrefix(self::SOURCE)],
+ ['cur.request_path']
+ )->joinLeft(
+ ['cp' => $this->source->addDocumentPrefix($this->cmsPageTableName)],
+ 'cur.request_path = cp.identifier',
+ []
+ );
+
+ return $select;
+ }
+
/**
* @inheritdoc
*/
@@ -340,6 +364,9 @@ protected function selectCmsPageRewrites()
[]
)->where(
'cp.is_active = 1'
+ )->where(
+ 'cp.identifier NOT IN(?)',
+ $this->getUrlRewriteRequestPathsSelect()
)->group(['request_path', 'cps.store_id']);
return $select;
@@ -348,22 +375,18 @@ protected function selectCmsPageRewrites()
/**
* @return void
*/
- protected function collectCmsPageRewrites()
+ protected function saveCmsPageRewrites()
{
$select = $this->selectCmsPageRewrites();
$urlRewrites = $this->source->getAdapter()->loadDataFromSelect($select);
- $this->destination->saveRecords(self::DESTINATION, $urlRewrites);
+ $this->destination->saveRecords(self::DESTINATION, $urlRewrites, ['request_path' => 'request_path']);
}
/**
- * @param bool $countVolume
* @return int
*/
- protected function countCmsPageRewrites($countVolume = false)
+ protected function countCmsPageRewrites()
{
- if (!$countVolume) {
- return 1;
- }
$select = $this->selectCmsPageRewrites();
$urlRewrites = $this->source->getAdapter()->loadDataFromSelect($select);
return count($urlRewrites);
diff --git a/tests/integration/framework/Helper.php b/tests/integration/framework/Helper.php
index 17f728565..6b3b508d1 100644
--- a/tests/integration/framework/Helper.php
+++ b/tests/integration/framework/Helper.php
@@ -112,7 +112,9 @@ public function getObjectManager()
]
]
]
- ]
+ ],
+ 'Migration\ResourceModel\Source' => ['shared' => false],
+ 'Migration\ResourceModel\Destination' => ['shared' => false],
]);
return $this->objectManager;
}
diff --git a/tests/integration/resource/eav/dest.sql b/tests/integration/resource/eav/dest.sql
index 9908dd785..94d20610c 100644
--- a/tests/integration/resource/eav/dest.sql
+++ b/tests/integration/resource/eav/dest.sql
@@ -133,6 +133,7 @@ ENGINE=InnoDB
;
INSERT INTO `eav_attribute_group` (`attribute_group_id`, `attribute_set_id`, `attribute_group_name`, `sort_order`, `default_id`, `attribute_group_code`, `tab_group_code`) VALUES (7, 4, 'Product Details', 10, 1, 'product-details', 'basic');
INSERT INTO `eav_attribute_group` (`attribute_group_id`, `attribute_set_id`, `attribute_group_name`, `sort_order`, `default_id`, `attribute_group_code`, `tab_group_code`) VALUES (1, 1, 'General', 1, 1, NULL, NULL);
+INSERT INTO `eav_attribute_group` (`attribute_group_id`, `attribute_set_id`, `attribute_group_name`, `sort_order`, `default_id`, `attribute_group_code`, `tab_group_code`) VALUES (8, 4, 'Design', 11, 1, 'design', 'advanced');
CREATE TABLE `eav_entity_attribute` (
`entity_attribute_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Entity Attribute Id',
diff --git a/tests/integration/resource/eav/source.sql b/tests/integration/resource/eav/source.sql
index 2eed9730b..1893966f4 100644
--- a/tests/integration/resource/eav/source.sql
+++ b/tests/integration/resource/eav/source.sql
@@ -127,6 +127,8 @@ ENGINE=InnoDB
;
INSERT INTO `eav_attribute_group` (`attribute_group_id`, `attribute_set_id`, `attribute_group_name`, `sort_order`, `default_id`) VALUES (4, 4, 'General', 1, 1);
INSERT INTO `eav_attribute_group` (`attribute_group_id`, `attribute_set_id`, `attribute_group_name`, `sort_order`, `default_id`) VALUES (1, 1, 'General', 1, 1);
+INSERT INTO `eav_attribute_group` (`attribute_group_id`, `attribute_set_id`, `attribute_group_name`, `sort_order`, `default_id`) VALUES (5, 4, 'Prices', 2, 0);
+INSERT INTO `eav_attribute_group` (`attribute_group_id`, `attribute_set_id`, `attribute_group_name`, `sort_order`, `default_id`) VALUES (6, 4, 'Design', 3, 0);
CREATE TABLE `eav_entity_attribute` (
`entity_attribute_id` INT(10) UNSIGNED NOT NULL COMMENT 'Entity Attribute Id',
diff --git a/tests/integration/resource/ee.eav/dest.sql b/tests/integration/resource/ee.eav/dest.sql
index 61e4d8844..145944215 100644
--- a/tests/integration/resource/ee.eav/dest.sql
+++ b/tests/integration/resource/ee.eav/dest.sql
@@ -133,6 +133,7 @@ ENGINE=InnoDB
;
INSERT INTO `eav_attribute_group` (`attribute_group_id`, `attribute_set_id`, `attribute_group_name`, `sort_order`, `default_id`, `attribute_group_code`, `tab_group_code`) VALUES (7, 4, 'Product Details', 10, 1, 'product-details', 'basic');
INSERT INTO `eav_attribute_group` (`attribute_group_id`, `attribute_set_id`, `attribute_group_name`, `sort_order`, `default_id`, `attribute_group_code`, `tab_group_code`) VALUES (1, 1, 'General', 1, 1, NULL, NULL);
+INSERT INTO `eav_attribute_group` (`attribute_group_id`, `attribute_set_id`, `attribute_group_name`, `sort_order`, `default_id`, `attribute_group_code`, `tab_group_code`) VALUES (8, 4, 'Design', 11, 1, 'design', 'advanced');
CREATE TABLE `eav_entity_attribute` (
`entity_attribute_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Entity Attribute Id',
diff --git a/tests/integration/resource/ee.eav/source.sql b/tests/integration/resource/ee.eav/source.sql
index 45e77d3e3..2cddcf89f 100644
--- a/tests/integration/resource/ee.eav/source.sql
+++ b/tests/integration/resource/ee.eav/source.sql
@@ -127,6 +127,8 @@ ENGINE=InnoDB
;
INSERT INTO `eav_attribute_group` (`attribute_group_id`, `attribute_set_id`, `attribute_group_name`, `sort_order`, `default_id`) VALUES (4, 4, 'General', 1, 1);
INSERT INTO `eav_attribute_group` (`attribute_group_id`, `attribute_set_id`, `attribute_group_name`, `sort_order`, `default_id`) VALUES (1, 1, 'General', 1, 1);
+INSERT INTO `eav_attribute_group` (`attribute_group_id`, `attribute_set_id`, `attribute_group_name`, `sort_order`, `default_id`) VALUES (5, 4, 'Prices', 2, 0);
+INSERT INTO `eav_attribute_group` (`attribute_group_id`, `attribute_set_id`, `attribute_group_name`, `sort_order`, `default_id`) VALUES (6, 4, 'Design', 3, 0);
CREATE TABLE `eav_entity_attribute` (
`entity_attribute_id` INT(10) UNSIGNED NOT NULL COMMENT 'Entity Attribute Id',
diff --git a/tests/integration/resource/ee.url_rewrite/dest.sql b/tests/integration/resource/ee.url_rewrite_11410/dest.sql
similarity index 100%
rename from tests/integration/resource/ee.url_rewrite/dest.sql
rename to tests/integration/resource/ee.url_rewrite_11410/dest.sql
diff --git a/tests/integration/resource/ee.url_rewrite/source.sql b/tests/integration/resource/ee.url_rewrite_11410/source.sql
similarity index 100%
rename from tests/integration/resource/ee.url_rewrite/source.sql
rename to tests/integration/resource/ee.url_rewrite_11410/source.sql
diff --git a/tests/integration/resource/url_rewrite/dest.sql b/tests/integration/resource/ee.url_rewrite_191/dest.sql
similarity index 100%
rename from tests/integration/resource/url_rewrite/dest.sql
rename to tests/integration/resource/ee.url_rewrite_191/dest.sql
diff --git a/tests/integration/resource/ee.url_rewrite_191/source.sql b/tests/integration/resource/ee.url_rewrite_191/source.sql
new file mode 100644
index 000000000..392984739
--- /dev/null
+++ b/tests/integration/resource/ee.url_rewrite_191/source.sql
@@ -0,0 +1,179 @@
+/**
+ * Copyright © 2016 Magento. All rights reserved.
+ * See COPYING.txt for license details.
+ */
+
+/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
+/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
+/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
+/*!40101 SET NAMES utf8 */;
+/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
+/*!40103 SET TIME_ZONE='+00:00' */;
+/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
+/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
+/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
+/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
+
+DROP TABLE IF EXISTS `core_store`;
+CREATE TABLE `core_store` (
+ `store_id` SMALLINT(5) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Store Id',
+ `code` VARCHAR(32) NULL DEFAULT NULL COMMENT 'Code',
+ `website_id` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Website Id',
+ `group_id` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Group Id',
+ `name` VARCHAR(255) NOT NULL COMMENT 'Store Name',
+ `sort_order` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Store Sort Order',
+ `is_active` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Store Activity',
+ PRIMARY KEY (`store_id`),
+ UNIQUE INDEX `UNQ_CORE_STORE_CODE` (`code`),
+ INDEX `IDX_CORE_STORE_WEBSITE_ID` (`website_id`),
+ INDEX `IDX_CORE_STORE_IS_ACTIVE_SORT_ORDER` (`is_active`, `sort_order`),
+ INDEX `IDX_CORE_STORE_GROUP_ID` (`group_id`),
+ CONSTRAINT `FK_CORE_STORE_GROUP_ID_CORE_STORE_GROUP_GROUP_ID` FOREIGN KEY (`group_id`) REFERENCES `core_store_group` (`group_id`) ON UPDATE CASCADE ON DELETE CASCADE,
+ CONSTRAINT `FK_CORE_STORE_WEBSITE_ID_CORE_WEBSITE_WEBSITE_ID` FOREIGN KEY (`website_id`) REFERENCES `core_website` (`website_id`) ON UPDATE CASCADE ON DELETE CASCADE
+)
+COMMENT='Stores'
+COLLATE='utf8_general_ci'
+ENGINE=InnoDB
+;
+
+LOCK TABLES `core_store` WRITE;
+/*!40000 ALTER TABLE `core_store` DISABLE KEYS */;
+INSERT INTO `core_store` VALUES
+(0,'admin',0,0,'Admin',0,1),
+(1,'default',1,1,'Default Store View',0,1),
+(2,'de',1,1,'German',0,1),
+(3,'mw_store_02',1,2,'MWStore View02',0,1);
+/*!40000 ALTER TABLE `core_store` ENABLE KEYS */;
+UNLOCK TABLES;
+
+DROP TABLE IF EXISTS `cms_page`;
+CREATE TABLE `cms_page` (
+ `page_id` SMALLINT(6) NOT NULL AUTO_INCREMENT COMMENT 'Page ID',
+ `title` VARCHAR(255) NULL DEFAULT NULL COMMENT 'Page Title',
+ `root_template` VARCHAR(255) NULL DEFAULT NULL COMMENT 'Page Template',
+ `meta_keywords` TEXT NULL COMMENT 'Page Meta Keywords',
+ `meta_description` TEXT NULL COMMENT 'Page Meta Description',
+ `identifier` VARCHAR(100) NOT NULL COMMENT 'Page String Identifier',
+ `content_heading` VARCHAR(255) NULL DEFAULT NULL COMMENT 'Page Content Heading',
+ `content` MEDIUMTEXT NULL COMMENT 'Page Content',
+ `creation_time` TIMESTAMP NULL DEFAULT NULL COMMENT 'Page Creation Time',
+ `update_time` TIMESTAMP NULL DEFAULT NULL COMMENT 'Page Modification Time',
+ `is_active` SMALLINT(6) NOT NULL DEFAULT '1' COMMENT 'Is Page Active',
+ `sort_order` SMALLINT(6) NOT NULL DEFAULT '0' COMMENT 'Page Sort Order',
+ `layout_update_xml` TEXT NULL COMMENT 'Page Layout Update Content',
+ `custom_theme` VARCHAR(100) NULL DEFAULT NULL COMMENT 'Page Custom Theme',
+ `custom_root_template` VARCHAR(255) NULL DEFAULT NULL COMMENT 'Page Custom Template',
+ `custom_layout_update_xml` TEXT NULL COMMENT 'Page Custom Layout Update Content',
+ `custom_theme_from` DATE NULL DEFAULT NULL COMMENT 'Page Custom Theme Active From Date',
+ `custom_theme_to` DATE NULL DEFAULT NULL COMMENT 'Page Custom Theme Active To Date',
+ `published_revision_id` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Published Revision Id',
+ `website_root` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '1' COMMENT 'Website Root',
+ `under_version_control` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Under Version Control Flag',
+ PRIMARY KEY (`page_id`),
+ INDEX `IDX_CMS_PAGE_IDENTIFIER` (`identifier`)
+)
+COMMENT='CMS Page Table'
+COLLATE='utf8_general_ci'
+ENGINE=InnoDB
+;
+INSERT INTO `cms_page` VALUES
+(1, '404 Not Found 1', 'two_columns_right', 'Page keywords', 'Page description', 'no-route', '', 'We’re sorry, the page you’re looking for can not be found.
\n\n
\n - If you typed the URL directly, please make sure the spelling is correct.
\n - If you clicked on a link to get here, we must have moved the content.
Please try our store search box above to search for an item. \n - If you are not sure how you got here, go back to the previous page or return to our store homepage.
\n
\n
\n\n', '2007-06-20 18:38:32', '2007-08-26 19:11:13', 1, 0, NULL, NULL, '', NULL, NULL, NULL, 1, 1, 0);
+
+DROP TABLE IF EXISTS `cms_page_store`;
+CREATE TABLE `cms_page_store` (
+ `page_id` SMALLINT(6) NOT NULL COMMENT 'Page ID',
+ `store_id` SMALLINT(5) UNSIGNED NOT NULL COMMENT 'Store ID',
+ PRIMARY KEY (`page_id`, `store_id`),
+ INDEX `IDX_CMS_PAGE_STORE_STORE_ID` (`store_id`),
+ CONSTRAINT `FK_CMS_PAGE_STORE_PAGE_ID_CMS_PAGE_PAGE_ID` FOREIGN KEY (`page_id`) REFERENCES `cms_page` (`page_id`) ON UPDATE CASCADE ON DELETE CASCADE,
+ CONSTRAINT `FK_CMS_PAGE_STORE_STORE_ID_CORE_STORE_STORE_ID` FOREIGN KEY (`store_id`) REFERENCES `core_store` (`store_id`) ON UPDATE CASCADE ON DELETE CASCADE
+)
+COMMENT='CMS Page To Store Linkage Table'
+COLLATE='utf8_general_ci'
+ENGINE=InnoDB
+;
+INSERT INTO `cms_page_store` VALUES (1, 0);
+
+DROP TABLE IF EXISTS `core_url_rewrite`;
+CREATE TABLE `core_url_rewrite` (
+ `url_rewrite_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Rewrite Id',
+ `store_id` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Store Id',
+ `category_id` INT(10) UNSIGNED NULL DEFAULT NULL COMMENT 'Category Id',
+ `product_id` INT(10) UNSIGNED NULL DEFAULT NULL COMMENT 'Product Id',
+ `id_path` VARCHAR(255) NULL DEFAULT NULL COMMENT 'Id Path',
+ `request_path` VARCHAR(255) NULL DEFAULT NULL COMMENT 'Request Path',
+ `target_path` VARCHAR(255) NULL DEFAULT NULL COMMENT 'Target Path',
+ `is_system` SMALLINT(5) UNSIGNED NULL DEFAULT '1' COMMENT 'Defines is Rewrite System',
+ `options` VARCHAR(255) NULL DEFAULT NULL COMMENT 'Options',
+ `description` VARCHAR(255) NULL DEFAULT NULL COMMENT 'Deascription',
+ PRIMARY KEY (`url_rewrite_id`),
+ UNIQUE INDEX `UNQ_CORE_URL_REWRITE_REQUEST_PATH_STORE_ID` (`request_path`, `store_id`),
+ UNIQUE INDEX `UNQ_CORE_URL_REWRITE_ID_PATH_IS_SYSTEM_STORE_ID` (`id_path`, `is_system`, `store_id`),
+ INDEX `IDX_CORE_URL_REWRITE_TARGET_PATH_STORE_ID` (`target_path`, `store_id`),
+ INDEX `IDX_CORE_URL_REWRITE_ID_PATH` (`id_path`),
+ INDEX `IDX_CORE_URL_REWRITE_STORE_ID` (`store_id`),
+ INDEX `FK_CORE_URL_REWRITE_PRODUCT_ID_CATALOG_PRODUCT_ENTITY_ENTITY_ID` (`product_id`),
+ INDEX `FK_CORE_URL_REWRITE_CTGR_ID_CAT_CTGR_ENTT_ENTT_ID` (`category_id`),
+ CONSTRAINT `FK_CORE_URL_REWRITE_CTGR_ID_CAT_CTGR_ENTT_ENTT_ID` FOREIGN KEY (`category_id`) REFERENCES `catalog_category_entity` (`entity_id`) ON UPDATE CASCADE ON DELETE CASCADE,
+ CONSTRAINT `FK_CORE_URL_REWRITE_PRODUCT_ID_CATALOG_PRODUCT_ENTITY_ENTITY_ID` FOREIGN KEY (`product_id`) REFERENCES `catalog_product_entity` (`entity_id`) ON UPDATE CASCADE ON DELETE CASCADE,
+ CONSTRAINT `FK_CORE_URL_REWRITE_STORE_ID_CORE_STORE_STORE_ID` FOREIGN KEY (`store_id`) REFERENCES `core_store` (`store_id`) ON UPDATE CASCADE ON DELETE CASCADE
+)
+COMMENT='Url Rewrites'
+COLLATE='utf8_general_ci'
+ENGINE=InnoDB
+;
+INSERT INTO `core_url_rewrite` VALUES
+(1, 0, 1, 1, '1', 'test1.htm', 'contacts', 1, NULL, NULL),
+(2, 1, 1, 1, '2', 'test1.htm', 'catalog/category/view/id/6', 1, NULL, NULL),
+(3, 0, 2, 2, '3', 'test5.htm', 'contacts', 1, NULL, NULL),
+(4, 1, 2, 2, '3', NULL, 'catalog/category/view/id/8', 1, NULL, NULL);
+
+
+DROP TABLE IF EXISTS `catalog_category_entity`;
+CREATE TABLE `catalog_category_entity` (
+ `entity_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Entity ID',
+ `entity_type_id` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Entity Type ID',
+ `attribute_set_id` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Attriute Set ID',
+ `parent_id` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Parent Category ID',
+ `created_at` TIMESTAMP NULL DEFAULT NULL COMMENT 'Creation Time',
+ `updated_at` TIMESTAMP NULL DEFAULT NULL COMMENT 'Update Time',
+ `path` VARCHAR(255) NOT NULL COMMENT 'Tree Path',
+ `position` INT(11) NOT NULL DEFAULT '0' COMMENT 'Position',
+ `level` INT(11) NOT NULL DEFAULT '0' COMMENT 'Tree Level',
+ `children_count` INT(11) NOT NULL DEFAULT '0' COMMENT 'Child Count',
+ PRIMARY KEY (`entity_id`),
+ INDEX `IDX_CATALOG_CATEGORY_ENTITY_LEVEL` (`level`),
+ INDEX `IDX_CATALOG_CATEGORY_ENTITY_PATH_ENTITY_ID` (`path`, `entity_id`)
+)
+COMMENT='Catalog Category Table'
+COLLATE='utf8_general_ci'
+ENGINE=InnoDB
+;
+INSERT INTO `catalog_category_entity` VALUES (1, 3, 0, 0, '0000-00-00 00:00:00', '2016-07-13 11:43:28', '1', 0, 0, 2),
+(2, 3, 3, 1, '2016-07-13 11:43:28', '2016-07-13 11:43:28', '1/2', 1, 1, 1),
+(3, 3, 3, 2, '2016-07-13 12:30:21', '2016-07-13 12:30:21', '1/2/3', 1, 2, 0);
+
+CREATE TABLE `catalog_product_entity` (
+ `entity_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Entity ID',
+ `entity_type_id` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Entity Type ID',
+ `attribute_set_id` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Attribute Set ID',
+ `type_id` VARCHAR(32) NOT NULL DEFAULT 'simple' COMMENT 'Type ID',
+ `sku` VARCHAR(64) NULL DEFAULT NULL COMMENT 'SKU',
+ `has_options` SMALLINT(6) NOT NULL DEFAULT '0' COMMENT 'Has Options',
+ `required_options` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Required Options',
+ `created_at` TIMESTAMP NULL DEFAULT NULL COMMENT 'Creation Time',
+ `updated_at` TIMESTAMP NULL DEFAULT NULL COMMENT 'Update Time',
+ PRIMARY KEY (`entity_id`),
+ INDEX `IDX_CATALOG_PRODUCT_ENTITY_ENTITY_TYPE_ID` (`entity_type_id`),
+ INDEX `IDX_CATALOG_PRODUCT_ENTITY_ATTRIBUTE_SET_ID` (`attribute_set_id`),
+ INDEX `IDX_CATALOG_PRODUCT_ENTITY_SKU` (`sku`),
+ CONSTRAINT `FK_CAT_PRD_ENTT_ATTR_SET_ID_EAV_ATTR_SET_ATTR_SET_ID` FOREIGN KEY (`attribute_set_id`) REFERENCES `eav_attribute_set` (`attribute_set_id`) ON UPDATE CASCADE ON DELETE CASCADE,
+ CONSTRAINT `FK_CAT_PRD_ENTT_ENTT_TYPE_ID_EAV_ENTT_TYPE_ENTT_TYPE_ID` FOREIGN KEY (`entity_type_id`) REFERENCES `eav_entity_type` (`entity_type_id`) ON UPDATE CASCADE ON DELETE CASCADE
+)
+COMMENT='Catalog Product Table'
+COLLATE='utf8_general_ci'
+ENGINE=InnoDB
+;
+INSERT INTO `catalog_product_entity` VALUES
+(1, 4, 4, 'simple', 'SimpleProduct', 1, 1, '2016-07-13 12:31:52', '2016-07-13 12:34:07'),
+(2, 4, 4, 'virtual', 'Virtual Product', 0, 0, '2016-07-13 12:34:53', '2016-07-13 12:34:53');
diff --git a/tests/integration/resource/sales_increment/dest.sql b/tests/integration/resource/sales_increment/dest.sql
new file mode 100644
index 000000000..563e4b790
--- /dev/null
+++ b/tests/integration/resource/sales_increment/dest.sql
@@ -0,0 +1,94 @@
+/**
+ * Copyright © 2016 Magento. All rights reserved.
+ * See COPYING.txt for license details.
+ */
+
+/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
+/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
+/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
+/*!40101 SET NAMES utf8 */;
+/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
+/*!40103 SET TIME_ZONE='+00:00' */;
+/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
+/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
+/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
+/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
+
+DROP TABLE IF EXISTS `sales_sequence_meta`;
+CREATE TABLE `sales_sequence_meta` (
+ `meta_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Id',
+ `entity_type` VARCHAR(32) NOT NULL COMMENT 'Prefix',
+ `store_id` SMALLINT(5) UNSIGNED NOT NULL COMMENT 'Store Id',
+ `sequence_table` VARCHAR(32) NOT NULL COMMENT 'table for sequence',
+ PRIMARY KEY (`meta_id`),
+ UNIQUE INDEX `SALES_SEQUENCE_META_ENTITY_TYPE_STORE_ID` (`entity_type`, `store_id`)
+)
+COMMENT='sales_sequence_meta'
+COLLATE='utf8_general_ci'
+ENGINE=InnoDB
+;
+DROP TABLE IF EXISTS `sales_sequence_profile`;
+CREATE TABLE `sales_sequence_profile` (
+ `profile_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Id',
+ `meta_id` INT(10) UNSIGNED NOT NULL COMMENT 'Meta_id',
+ `prefix` VARCHAR(32) NULL DEFAULT NULL COMMENT 'Prefix',
+ `suffix` VARCHAR(32) NULL DEFAULT NULL COMMENT 'Suffix',
+ `start_value` INT(10) UNSIGNED NOT NULL DEFAULT '1' COMMENT 'Start value for sequence',
+ `step` INT(10) UNSIGNED NOT NULL DEFAULT '1' COMMENT 'Step for sequence',
+ `max_value` INT(10) UNSIGNED NOT NULL COMMENT 'MaxValue for sequence',
+ `warning_value` INT(10) UNSIGNED NOT NULL COMMENT 'WarningValue for sequence',
+ `is_active` TINYINT(1) NOT NULL DEFAULT '0' COMMENT 'isActive flag',
+ PRIMARY KEY (`profile_id`),
+ UNIQUE INDEX `SALES_SEQUENCE_PROFILE_META_ID_PREFIX_SUFFIX` (`meta_id`, `prefix`, `suffix`),
+ CONSTRAINT `SALES_SEQUENCE_PROFILE_META_ID_SALES_SEQUENCE_META_META_ID` FOREIGN KEY (`meta_id`) REFERENCES `sales_sequence_meta` (`meta_id`) ON DELETE CASCADE
+)
+COMMENT='sales_sequence_profile'
+COLLATE='utf8_general_ci'
+ENGINE=InnoDB
+;
+
+DROP TABLE IF EXISTS `eav_entity_type`;
+CREATE TABLE `eav_entity_type` (
+ `entity_type_id` SMALLINT(5) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Entity Type Id',
+ `entity_type_code` VARCHAR(50) NOT NULL COMMENT 'Entity Type Code',
+ `entity_model` VARCHAR(255) NOT NULL COMMENT 'Entity Model',
+ `attribute_model` VARCHAR(255) NULL DEFAULT NULL COMMENT 'Attribute Model',
+ `entity_table` VARCHAR(255) NULL DEFAULT NULL COMMENT 'Entity Table',
+ `value_table_prefix` VARCHAR(255) NULL DEFAULT NULL COMMENT 'Value Table Prefix',
+ `entity_id_field` VARCHAR(255) NULL DEFAULT NULL COMMENT 'Entity Id Field',
+ `is_data_sharing` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '1' COMMENT 'Defines Is Data Sharing',
+ `data_sharing_key` VARCHAR(100) NULL DEFAULT 'default' COMMENT 'Data Sharing Key',
+ `default_attribute_set_id` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Default Attribute Set Id',
+ `increment_model` VARCHAR(255) NULL DEFAULT NULL COMMENT 'Increment Model',
+ `increment_per_store` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Increment Per Store',
+ `increment_pad_length` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '8' COMMENT 'Increment Pad Length',
+ `increment_pad_char` VARCHAR(1) NOT NULL DEFAULT '0' COMMENT 'Increment Pad Char',
+ `additional_attribute_table` VARCHAR(255) NULL DEFAULT NULL COMMENT 'Additional Attribute Table',
+ `entity_attribute_collection` VARCHAR(255) NULL DEFAULT NULL COMMENT 'Entity Attribute Collection',
+ PRIMARY KEY (`entity_type_id`),
+ INDEX `IDX_EAV_ENTITY_TYPE_ENTITY_TYPE_CODE` (`entity_type_code`)
+)
+COMMENT='Eav Entity Type'
+COLLATE='utf8_general_ci'
+ENGINE=InnoDB
+;
+INSERT INTO `eav_entity_type` VALUES
+(11, 'order', 'Magento\\Sales\\Model\\ResourceModel\\Order', NULL, 'sales_order', '', '', 1, 'default', 11, 'Magento\\Eav\\Model\\Entity\\Increment\\NumericValue', 1, 8, '0', NULL, NULL),
+(16, 'invoice', 'Magento\\Sales\\Model\\ResourceModel\\Order\\Invoice', NULL, 'sales_order_entity', '', '', 1, 'default', 16, 'Magento\\Eav\\Model\\Entity\\Increment\\NumericValue', 1, 8, '0', NULL, NULL),
+(19, 'shipment', 'Magento\\Sales\\Model\\ResourceModel\\Order\\Shipment', NULL, 'sales_order_entity', '', '', 1, 'default', 19, 'Magento\\Eav\\Model\\Entity\\Increment\\NumericValue', 1, 8, '0', NULL, NULL),
+(23, 'creditmemo', 'Magento\\Sales\\Model\\ResourceModel\\Order\\Creditmemo', NULL, 'sales_order_entity', '', '', 1, 'default', 23, 'Magento\\Eav\\Model\\Entity\\Increment\\NumericValue', 1, 8, '0', NULL, NULL),
+(26, 'rma_item', 'Magento\\Rma\\Model\\ResourceModel\\Item', 'Magento\\Rma\\Model\\Item\\Attribute', 'magento_rma_item_entity', NULL, NULL, 1, 'default', 27, 'Magento\\Eav\\Model\\Entity\\Increment\\NumericValue', 1, 8, '0', 'magento_rma_item_eav_attribute', NULL);
+
+
+
+/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
+
+/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
+/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
+/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
+/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
+/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
+/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
+/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
+
+-- Dump completed on 2015-01-29 19:44:27
diff --git a/tests/integration/resource/sales_increment/source.sql b/tests/integration/resource/sales_increment/source.sql
new file mode 100644
index 000000000..6a90c6fd5
--- /dev/null
+++ b/tests/integration/resource/sales_increment/source.sql
@@ -0,0 +1,93 @@
+/**
+ * Copyright © 2016 Magento. All rights reserved.
+ * See COPYING.txt for license details.
+ */
+
+/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
+/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
+/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
+/*!40101 SET NAMES utf8 */;
+/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
+/*!40103 SET TIME_ZONE='+00:00' */;
+/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
+/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
+/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
+/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
+
+DROP TABLE IF EXISTS `core_store`;
+CREATE TABLE `core_store` (
+ `store_id` SMALLINT(5) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Store Id',
+ `code` VARCHAR(32) NULL DEFAULT NULL COMMENT 'Code',
+ `website_id` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Website Id',
+ `group_id` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Group Id',
+ `name` VARCHAR(255) NOT NULL COMMENT 'Store Name',
+ `sort_order` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Store Sort Order',
+ `is_active` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Store Activity',
+ PRIMARY KEY (`store_id`),
+ UNIQUE INDEX `UNQ_CORE_STORE_CODE` (`code`),
+ INDEX `IDX_CORE_STORE_WEBSITE_ID` (`website_id`),
+ INDEX `IDX_CORE_STORE_IS_ACTIVE_SORT_ORDER` (`is_active`, `sort_order`),
+ INDEX `IDX_CORE_STORE_GROUP_ID` (`group_id`),
+ CONSTRAINT `FK_CORE_STORE_GROUP_ID_CORE_STORE_GROUP_GROUP_ID` FOREIGN KEY (`group_id`) REFERENCES `core_store_group` (`group_id`) ON UPDATE CASCADE ON DELETE CASCADE,
+ CONSTRAINT `FK_CORE_STORE_WEBSITE_ID_CORE_WEBSITE_WEBSITE_ID` FOREIGN KEY (`website_id`) REFERENCES `core_website` (`website_id`) ON UPDATE CASCADE ON DELETE CASCADE
+)
+COMMENT='Stores'
+COLLATE='utf8_general_ci'
+ENGINE=InnoDB
+;
+INSERT INTO `core_store` VALUES
+(0, 'admin', 0, 0, 'Admin', 0, 1),
+(1, 'default', 1, 1, 'Default Store View', 0, 1);
+
+DROP TABLE IF EXISTS `core_store_group`;
+CREATE TABLE `core_store_group` (
+ `group_id` SMALLINT(5) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Group Id',
+ `website_id` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Website Id',
+ `name` VARCHAR(255) NOT NULL COMMENT 'Store Group Name',
+ `root_category_id` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Root Category Id',
+ `default_store_id` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Default Store Id',
+ PRIMARY KEY (`group_id`),
+ INDEX `IDX_CORE_STORE_GROUP_WEBSITE_ID` (`website_id`),
+ INDEX `IDX_CORE_STORE_GROUP_DEFAULT_STORE_ID` (`default_store_id`),
+ CONSTRAINT `FK_CORE_STORE_GROUP_WEBSITE_ID_CORE_WEBSITE_WEBSITE_ID` FOREIGN KEY (`website_id`) REFERENCES `core_website` (`website_id`) ON UPDATE CASCADE ON DELETE CASCADE
+)
+COMMENT='Store Groups'
+COLLATE='utf8_general_ci'
+ENGINE=InnoDB
+;
+INSERT INTO `core_store_group` VALUES
+(0, 0, 'Default', 0, 0),
+(1, 1, 'Main Website Store', 2, 1);
+
+DROP TABLE IF EXISTS `eav_entity_store`;
+CREATE TABLE `eav_entity_store` (
+ `entity_store_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Entity Store Id',
+ `entity_type_id` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Entity Type Id',
+ `store_id` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Store Id',
+ `increment_prefix` VARCHAR(20) NULL DEFAULT NULL COMMENT 'Increment Prefix',
+ `increment_last_id` VARCHAR(50) NULL DEFAULT NULL COMMENT 'Last Incremented Id',
+ PRIMARY KEY (`entity_store_id`),
+ INDEX `IDX_EAV_ENTITY_STORE_ENTITY_TYPE_ID` (`entity_type_id`),
+ INDEX `IDX_EAV_ENTITY_STORE_STORE_ID` (`store_id`),
+ CONSTRAINT `FK_EAV_ENTITY_STORE_STORE_ID_CORE_STORE_STORE_ID` FOREIGN KEY (`store_id`) REFERENCES `core_store` (`store_id`) ON UPDATE CASCADE ON DELETE CASCADE,
+ CONSTRAINT `FK_EAV_ENTT_STORE_ENTT_TYPE_ID_EAV_ENTT_TYPE_ENTT_TYPE_ID` FOREIGN KEY (`entity_type_id`) REFERENCES `eav_entity_type` (`entity_type_id`) ON UPDATE CASCADE ON DELETE CASCADE
+)
+COMMENT='Eav Entity Store'
+COLLATE='utf8_general_ci'
+ENGINE=InnoDB
+;
+INSERT INTO `eav_entity_store` VALUES
+(1, 1, 0, '0', '000000001'),
+(2, 11, 1, '1', '100000003'),
+(3, 16, 1, '1', '100000001'),
+(4, 19, 1, '1', '100000001');
+
+
+
+/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
+/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
+/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
+/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
+/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
+/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
+/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
\ No newline at end of file
diff --git a/tests/integration/resource/url_rewrite_11410/dest.sql b/tests/integration/resource/url_rewrite_11410/dest.sql
new file mode 100644
index 000000000..aee21de32
--- /dev/null
+++ b/tests/integration/resource/url_rewrite_11410/dest.sql
@@ -0,0 +1,128 @@
+/**
+ * Copyright © 2016 Magento. All rights reserved.
+ * See COPYING.txt for license details.
+ */
+
+/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
+/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
+/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
+/*!40101 SET NAMES utf8 */;
+/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
+/*!40103 SET TIME_ZONE='+00:00' */;
+/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
+/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
+/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
+/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
+
+--
+-- Table structure for table `url_rewrite`
+--
+
+DROP TABLE IF EXISTS `url_rewrite`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `url_rewrite` (
+ `url_rewrite_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Rewrite Id',
+ `entity_type` varchar(32) NOT NULL COMMENT 'Entity type code',
+ `entity_id` int(10) unsigned NOT NULL COMMENT 'Entity ID',
+ `request_path` varchar(255) DEFAULT NULL COMMENT 'Request Path',
+ `target_path` varchar(255) DEFAULT NULL COMMENT 'Target Path',
+ `redirect_type` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT 'Redirect Type',
+ `store_id` smallint(5) unsigned NOT NULL COMMENT 'Store Id',
+ `description` varchar(255) DEFAULT NULL COMMENT 'Description',
+ `is_autogenerated` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT 'Is rewrite generated automatically flag',
+ `metadata` varchar(255) DEFAULT NULL COMMENT 'Meta data for url rewrite',
+ PRIMARY KEY (`url_rewrite_id`),
+ UNIQUE KEY `UNQ_URL_REWRITE_REQUEST_PATH_STORE_ID` (`request_path`,`store_id`),
+ KEY `IDX_URL_REWRITE_TARGET_PATH` (`target_path`),
+ KEY `IDX_URL_REWRITE_STORE_ID_ENTITY_ID` (`store_id`,`entity_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Url Rewrites';
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Table structure for table `catalog_category_entity_varchar`
+--
+
+DROP TABLE IF EXISTS `catalog_category_entity_varchar`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `catalog_category_entity_varchar` (
+ `value_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Value ID',
+ `attribute_id` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT 'Attribute ID',
+ `store_id` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT 'Store ID',
+ `entity_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'Entity ID',
+ `value` varchar(255) DEFAULT NULL COMMENT 'Value',
+ PRIMARY KEY (`value_id`),
+ UNIQUE KEY `UNQ_CAT_CTGR_ENTT_VCHR_ENTT_TYPE_ID_ENTT_ID_ATTR_ID_STORE_ID` (`entity_id`,`attribute_id`,`store_id`),
+ KEY `IDX_CATALOG_CATEGORY_ENTITY_VARCHAR_ENTITY_ID` (`entity_id`),
+ KEY `IDX_CATALOG_CATEGORY_ENTITY_VARCHAR_ATTRIBUTE_ID` (`attribute_id`),
+ KEY `IDX_CATALOG_CATEGORY_ENTITY_VARCHAR_STORE_ID` (`store_id`)
+) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COMMENT='Catalog Category Varchar Attribute Backend Table';
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Dumping data for table `catalog_category_entity_varchar`
+--
+
+LOCK TABLES `catalog_category_entity_varchar` WRITE;
+/*!40000 ALTER TABLE `catalog_category_entity_varchar` DISABLE KEYS */;
+INSERT INTO `catalog_category_entity_varchar` VALUES
+(1,41,0,1,'Root Catalog'),
+(2,41,0,2,'Default Category'),
+(3,48,0,2,'PRODUCTS');
+/*!40000 ALTER TABLE `catalog_category_entity_varchar` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Table structure for table `catalog_product_entity_varchar`
+--
+
+DROP TABLE IF EXISTS `catalog_product_entity_varchar`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `catalog_product_entity_varchar` (
+ `value_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Value ID',
+ `attribute_id` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT 'Attribute ID',
+ `store_id` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT 'Store ID',
+ `entity_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'Entity ID',
+ `value` varchar(255) DEFAULT NULL COMMENT 'Value',
+ PRIMARY KEY (`value_id`),
+ UNIQUE KEY `UNQ_CAT_PRD_ENTT_VCHR_ENTT_ID_ATTR_ID_STORE_ID` (`entity_id`,`attribute_id`,`store_id`),
+ KEY `IDX_CATALOG_PRODUCT_ENTITY_VARCHAR_ATTRIBUTE_ID` (`attribute_id`),
+ KEY `IDX_CATALOG_PRODUCT_ENTITY_VARCHAR_STORE_ID` (`store_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Catalog Product Varchar Attribute Backend Table';
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Table structure for table `catalog_url_rewrite_product_category`
+--
+
+DROP TABLE IF EXISTS `catalog_url_rewrite_product_category`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `catalog_url_rewrite_product_category` (
+ `url_rewrite_id` int(10) unsigned NOT NULL COMMENT 'url_rewrite_id',
+ `category_id` int(10) unsigned NOT NULL COMMENT 'category_id',
+ `product_id` int(10) unsigned NOT NULL COMMENT 'product_id',
+ KEY `IDX_CATALOG_URL_REWRITE_PRODUCT_CATEGORY_CATEGORY_ID_PRODUCT_ID` (`category_id`,`product_id`),
+ KEY `FK_CAT_URL_REWRITE_PRD_CTGR_PRD_ID_CAT_PRD_ENTT_ENTT_ID` (`product_id`),
+ KEY `FK_BB79E64705D7F17FE181F23144528FC8` (`url_rewrite_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='url_rewrite_relation';
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Dumping data for table `catalog_url_rewrite_product_category`
+--
+
+
+/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
+
+/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
+/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
+/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
+/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
+/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
+/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
+/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
+
+-- Dump completed on 2015-01-29 19:44:27
diff --git a/tests/integration/resource/url_rewrite/source.sql b/tests/integration/resource/url_rewrite_11410/source.sql
similarity index 100%
rename from tests/integration/resource/url_rewrite/source.sql
rename to tests/integration/resource/url_rewrite_11410/source.sql
diff --git a/tests/integration/resource/url_rewrite_191/dest.sql b/tests/integration/resource/url_rewrite_191/dest.sql
new file mode 100644
index 000000000..aee21de32
--- /dev/null
+++ b/tests/integration/resource/url_rewrite_191/dest.sql
@@ -0,0 +1,128 @@
+/**
+ * Copyright © 2016 Magento. All rights reserved.
+ * See COPYING.txt for license details.
+ */
+
+/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
+/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
+/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
+/*!40101 SET NAMES utf8 */;
+/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
+/*!40103 SET TIME_ZONE='+00:00' */;
+/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
+/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
+/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
+/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
+
+--
+-- Table structure for table `url_rewrite`
+--
+
+DROP TABLE IF EXISTS `url_rewrite`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `url_rewrite` (
+ `url_rewrite_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Rewrite Id',
+ `entity_type` varchar(32) NOT NULL COMMENT 'Entity type code',
+ `entity_id` int(10) unsigned NOT NULL COMMENT 'Entity ID',
+ `request_path` varchar(255) DEFAULT NULL COMMENT 'Request Path',
+ `target_path` varchar(255) DEFAULT NULL COMMENT 'Target Path',
+ `redirect_type` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT 'Redirect Type',
+ `store_id` smallint(5) unsigned NOT NULL COMMENT 'Store Id',
+ `description` varchar(255) DEFAULT NULL COMMENT 'Description',
+ `is_autogenerated` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT 'Is rewrite generated automatically flag',
+ `metadata` varchar(255) DEFAULT NULL COMMENT 'Meta data for url rewrite',
+ PRIMARY KEY (`url_rewrite_id`),
+ UNIQUE KEY `UNQ_URL_REWRITE_REQUEST_PATH_STORE_ID` (`request_path`,`store_id`),
+ KEY `IDX_URL_REWRITE_TARGET_PATH` (`target_path`),
+ KEY `IDX_URL_REWRITE_STORE_ID_ENTITY_ID` (`store_id`,`entity_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Url Rewrites';
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Table structure for table `catalog_category_entity_varchar`
+--
+
+DROP TABLE IF EXISTS `catalog_category_entity_varchar`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `catalog_category_entity_varchar` (
+ `value_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Value ID',
+ `attribute_id` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT 'Attribute ID',
+ `store_id` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT 'Store ID',
+ `entity_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'Entity ID',
+ `value` varchar(255) DEFAULT NULL COMMENT 'Value',
+ PRIMARY KEY (`value_id`),
+ UNIQUE KEY `UNQ_CAT_CTGR_ENTT_VCHR_ENTT_TYPE_ID_ENTT_ID_ATTR_ID_STORE_ID` (`entity_id`,`attribute_id`,`store_id`),
+ KEY `IDX_CATALOG_CATEGORY_ENTITY_VARCHAR_ENTITY_ID` (`entity_id`),
+ KEY `IDX_CATALOG_CATEGORY_ENTITY_VARCHAR_ATTRIBUTE_ID` (`attribute_id`),
+ KEY `IDX_CATALOG_CATEGORY_ENTITY_VARCHAR_STORE_ID` (`store_id`)
+) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COMMENT='Catalog Category Varchar Attribute Backend Table';
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Dumping data for table `catalog_category_entity_varchar`
+--
+
+LOCK TABLES `catalog_category_entity_varchar` WRITE;
+/*!40000 ALTER TABLE `catalog_category_entity_varchar` DISABLE KEYS */;
+INSERT INTO `catalog_category_entity_varchar` VALUES
+(1,41,0,1,'Root Catalog'),
+(2,41,0,2,'Default Category'),
+(3,48,0,2,'PRODUCTS');
+/*!40000 ALTER TABLE `catalog_category_entity_varchar` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Table structure for table `catalog_product_entity_varchar`
+--
+
+DROP TABLE IF EXISTS `catalog_product_entity_varchar`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `catalog_product_entity_varchar` (
+ `value_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Value ID',
+ `attribute_id` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT 'Attribute ID',
+ `store_id` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT 'Store ID',
+ `entity_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'Entity ID',
+ `value` varchar(255) DEFAULT NULL COMMENT 'Value',
+ PRIMARY KEY (`value_id`),
+ UNIQUE KEY `UNQ_CAT_PRD_ENTT_VCHR_ENTT_ID_ATTR_ID_STORE_ID` (`entity_id`,`attribute_id`,`store_id`),
+ KEY `IDX_CATALOG_PRODUCT_ENTITY_VARCHAR_ATTRIBUTE_ID` (`attribute_id`),
+ KEY `IDX_CATALOG_PRODUCT_ENTITY_VARCHAR_STORE_ID` (`store_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Catalog Product Varchar Attribute Backend Table';
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Table structure for table `catalog_url_rewrite_product_category`
+--
+
+DROP TABLE IF EXISTS `catalog_url_rewrite_product_category`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `catalog_url_rewrite_product_category` (
+ `url_rewrite_id` int(10) unsigned NOT NULL COMMENT 'url_rewrite_id',
+ `category_id` int(10) unsigned NOT NULL COMMENT 'category_id',
+ `product_id` int(10) unsigned NOT NULL COMMENT 'product_id',
+ KEY `IDX_CATALOG_URL_REWRITE_PRODUCT_CATEGORY_CATEGORY_ID_PRODUCT_ID` (`category_id`,`product_id`),
+ KEY `FK_CAT_URL_REWRITE_PRD_CTGR_PRD_ID_CAT_PRD_ENTT_ENTT_ID` (`product_id`),
+ KEY `FK_BB79E64705D7F17FE181F23144528FC8` (`url_rewrite_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='url_rewrite_relation';
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Dumping data for table `catalog_url_rewrite_product_category`
+--
+
+
+/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
+
+/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
+/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
+/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
+/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
+/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
+/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
+/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
+
+-- Dump completed on 2015-01-29 19:44:27
diff --git a/tests/integration/resource/url_rewrite_191/source.sql b/tests/integration/resource/url_rewrite_191/source.sql
new file mode 100644
index 000000000..8cc3ab6c8
--- /dev/null
+++ b/tests/integration/resource/url_rewrite_191/source.sql
@@ -0,0 +1,256 @@
+DROP TABLE IF EXISTS `eav_entity_type`;
+CREATE TABLE IF NOT EXISTS `eav_entity_type` (
+ `entity_type_id` smallint(5) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Entity Type Id',
+ `entity_type_code` varchar(50) NOT NULL COMMENT 'Entity Type Code',
+ `entity_model` varchar(255) NOT NULL COMMENT 'Entity Model',
+ `attribute_model` varchar(255) DEFAULT NULL COMMENT 'Attribute Model',
+ `entity_table` varchar(255) DEFAULT NULL COMMENT 'Entity Table',
+ `value_table_prefix` varchar(255) DEFAULT NULL COMMENT 'Value Table Prefix',
+ `entity_id_field` varchar(255) DEFAULT NULL COMMENT 'Entity Id Field',
+ `is_data_sharing` smallint(5) unsigned NOT NULL DEFAULT '1' COMMENT 'Defines Is Data Sharing',
+ `data_sharing_key` varchar(100) DEFAULT 'default' COMMENT 'Data Sharing Key',
+ `default_attribute_set_id` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT 'Default Attribute Set Id',
+ `increment_model` varchar(255) DEFAULT NULL COMMENT 'Increment Model',
+ `increment_per_store` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT 'Increment Per Store',
+ `increment_pad_length` smallint(5) unsigned NOT NULL DEFAULT '8' COMMENT 'Increment Pad Length',
+ `increment_pad_char` varchar(1) NOT NULL DEFAULT '0' COMMENT 'Increment Pad Char',
+ `additional_attribute_table` varchar(255) DEFAULT NULL COMMENT 'Additional Attribute Table',
+ `entity_attribute_collection` varchar(255) DEFAULT NULL COMMENT 'Entity Attribute Collection',
+ PRIMARY KEY (`entity_type_id`),
+ KEY `EAV_ENTITY_TYPE_ENTITY_TYPE_CODE` (`entity_type_code`)
+)
+COMMENT='Eav Entity Type'
+COLLATE='utf8_general_ci'
+ENGINE=InnoDB
+;
+
+INSERT INTO `eav_entity_type` (`entity_type_id`, `entity_type_code`, `entity_model`, `attribute_model`, `entity_table`, `value_table_prefix`, `entity_id_field`, `is_data_sharing`, `data_sharing_key`, `default_attribute_set_id`, `increment_model`, `increment_per_store`, `increment_pad_length`, `increment_pad_char`, `additional_attribute_table`, `entity_attribute_collection`)
+VALUES (4, 'catalog_product', 'catalog/product', 'catalog/resource_eav_attribute', 'catalog/product', '', '', 1, 'default', 4, '', 0, 8, '0', 'catalog/eav_attribute', 'catalog/product_attribute_collection'),
+ (1, 'customer', 'customer/customer', 'customer/attribute', 'customer/entity', '', '', 1, 'default', 1, 'eav/entity_increment_numeric', 0, 8, '0', 'customer/eav_attribute', 'customer/attribute_collection');
+
+DROP TABLE IF EXISTS `eav_attribute_set`;
+CREATE TABLE IF NOT EXISTS `eav_attribute_set` (
+ `attribute_set_id` smallint(5) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Attribute Set Id',
+ `entity_type_id` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT 'Entity Type Id',
+ `attribute_set_name` varchar(255) DEFAULT NULL COMMENT 'Attribute Set Name',
+ `sort_order` smallint(6) NOT NULL DEFAULT '0' COMMENT 'Sort Order',
+ PRIMARY KEY (`attribute_set_id`),
+ UNIQUE KEY `EAV_ATTRIBUTE_SET_ENTITY_TYPE_ID_ATTRIBUTE_SET_NAME` (`entity_type_id`,`attribute_set_name`),
+ KEY `EAV_ATTRIBUTE_SET_ENTITY_TYPE_ID_SORT_ORDER` (`entity_type_id`,`sort_order`),
+ CONSTRAINT `EAV_ATTRIBUTE_SET_ENTITY_TYPE_ID_EAV_ENTITY_TYPE_ENTITY_TYPE_ID` FOREIGN KEY (`entity_type_id`) REFERENCES `eav_entity_type` (`entity_type_id`) ON DELETE CASCADE
+)
+COMMENT='Eav Attribute Set'
+COLLATE='utf8_general_ci'
+ENGINE=InnoDB
+;
+INSERT INTO `eav_attribute_set` (`attribute_set_id`, `entity_type_id`, `attribute_set_name`, `sort_order`)
+ VALUES (4, 4, 'Default', 1), (1, 1, 'Default', 1);
+
+DROP TABLE IF EXISTS `catalog_category_entity`;
+CREATE TABLE `catalog_category_entity` (
+ `entity_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Entity ID',
+ `entity_type_id` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Entity Type ID',
+ `attribute_set_id` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Attriute Set ID',
+ `parent_id` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Parent Category ID',
+ `created_at` TIMESTAMP NULL DEFAULT NULL COMMENT 'Creation Time',
+ `updated_at` TIMESTAMP NULL DEFAULT NULL COMMENT 'Update Time',
+ `path` VARCHAR(255) NOT NULL COMMENT 'Tree Path',
+ `position` INT(11) NOT NULL DEFAULT '0' COMMENT 'Position',
+ `level` INT(11) NOT NULL DEFAULT '0' COMMENT 'Tree Level',
+ `children_count` INT(11) NOT NULL DEFAULT '0' COMMENT 'Child Count',
+ PRIMARY KEY (`entity_id`),
+ INDEX `IDX_CATALOG_CATEGORY_ENTITY_LEVEL` (`level`),
+ INDEX `IDX_CATALOG_CATEGORY_ENTITY_PATH_ENTITY_ID` (`path`, `entity_id`)
+)
+COMMENT='Catalog Category Table'
+COLLATE='utf8_general_ci'
+ENGINE=InnoDB
+;
+INSERT INTO `catalog_category_entity` VALUES (1, 3, 0, 0, '0000-00-00 00:00:00', '2016-07-13 11:43:28', '1', 0, 0, 2),
+(2, 3, 3, 1, '2016-07-13 11:43:28', '2016-07-13 11:43:28', '1/2', 1, 1, 1),
+(3, 3, 3, 2, '2016-07-13 12:30:21', '2016-07-13 12:30:21', '1/2/3', 1, 2, 0);
+
+DROP TABLE IF EXISTS `catalog_product_entity`;
+CREATE TABLE `catalog_product_entity` (
+ `entity_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Entity ID',
+ `entity_type_id` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Entity Type ID',
+ `attribute_set_id` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Attribute Set ID',
+ `type_id` VARCHAR(32) NOT NULL DEFAULT 'simple' COMMENT 'Type ID',
+ `sku` VARCHAR(64) NULL DEFAULT NULL COMMENT 'SKU',
+ `has_options` SMALLINT(6) NOT NULL DEFAULT '0' COMMENT 'Has Options',
+ `required_options` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Required Options',
+ `created_at` TIMESTAMP NULL DEFAULT NULL COMMENT 'Creation Time',
+ `updated_at` TIMESTAMP NULL DEFAULT NULL COMMENT 'Update Time',
+ PRIMARY KEY (`entity_id`),
+ INDEX `IDX_CATALOG_PRODUCT_ENTITY_ENTITY_TYPE_ID` (`entity_type_id`),
+ INDEX `IDX_CATALOG_PRODUCT_ENTITY_ATTRIBUTE_SET_ID` (`attribute_set_id`),
+ INDEX `IDX_CATALOG_PRODUCT_ENTITY_SKU` (`sku`),
+ CONSTRAINT `FK_CAT_PRD_ENTT_ATTR_SET_ID_EAV_ATTR_SET_ATTR_SET_ID` FOREIGN KEY (`attribute_set_id`) REFERENCES `eav_attribute_set` (`attribute_set_id`) ON UPDATE CASCADE ON DELETE CASCADE
+)
+COMMENT='Catalog Product Table'
+COLLATE='utf8_general_ci'
+ENGINE=InnoDB
+;
+
+INSERT INTO `catalog_product_entity` VALUES
+(1, 4, 4, 'simple', 'SimpleProduct', 1, 1, '2016-07-13 12:31:52', '2016-07-13 12:34:07'),
+(2, 4, 4, 'virtual', 'Virtual Product', 0, 0, '2016-07-13 12:34:53', '2016-07-13 12:34:53');
+
+CREATE TABLE `core_website` (
+ `website_id` SMALLINT(5) UNSIGNED NOT NULL COMMENT 'Website Id',
+ `code` VARCHAR(32) NULL DEFAULT NULL COMMENT 'Code',
+ `name` VARCHAR(64) NULL DEFAULT NULL COMMENT 'Website Name',
+ `sort_order` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Sort Order',
+ `default_group_id` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Default Group Id',
+ `is_default` SMALLINT(5) UNSIGNED NULL DEFAULT '0' COMMENT 'Defines Is Website Default',
+ `is_staging` TINYINT(1) NOT NULL DEFAULT '0' COMMENT 'Is Staging Flag',
+ `master_login` VARCHAR(40) NULL DEFAULT NULL COMMENT 'Master Login',
+ `master_password` VARCHAR(100) NULL DEFAULT NULL COMMENT 'Master Password',
+ `visibility` VARCHAR(40) NULL DEFAULT NULL COMMENT 'Visibility',
+ PRIMARY KEY (`website_id`),
+ UNIQUE INDEX `UNQ_CORE_WEBSITE_CODE` (`code`),
+ INDEX `IDX_CORE_WEBSITE_SORT_ORDER` (`sort_order`),
+ INDEX `IDX_CORE_WEBSITE_DEFAULT_GROUP_ID` (`default_group_id`)
+)
+ COMMENT='Websites'
+ COLLATE='utf8_general_ci'
+ ENGINE=InnoDB
+;
+INSERT INTO `core_website` (`website_id`, `code`, `name`, `sort_order`, `default_group_id`, `is_default`, `is_staging`, `master_login`, `master_password`, `visibility`) VALUES (0, 'admin', 'Admin', 0, 0, 0, 0, '', '', '');
+INSERT INTO `core_website` (`website_id`, `code`, `name`, `sort_order`, `default_group_id`, `is_default`, `is_staging`, `master_login`, `master_password`, `visibility`) VALUES (1, 'base', 'Main Website', 0, 1, 1, 0, '', '', '');
+
+CREATE TABLE `core_store_group` (
+ `group_id` SMALLINT(5) UNSIGNED NOT NULL COMMENT 'Group Id',
+ `website_id` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Website Id',
+ `name` VARCHAR(255) NOT NULL COMMENT 'Store Group Name',
+ `root_category_id` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Root Category Id',
+ `default_store_id` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Default Store Id',
+ PRIMARY KEY (`group_id`),
+ INDEX `IDX_CORE_STORE_GROUP_WEBSITE_ID` (`website_id`),
+ INDEX `IDX_CORE_STORE_GROUP_DEFAULT_STORE_ID` (`default_store_id`),
+ CONSTRAINT `FK_CORE_STORE_GROUP_WEBSITE_ID_CORE_WEBSITE_WEBSITE_ID` FOREIGN KEY (`website_id`) REFERENCES `core_website` (`website_id`) ON UPDATE CASCADE ON DELETE CASCADE
+)
+ COMMENT='Store Groups'
+ COLLATE='utf8_general_ci'
+ ENGINE=InnoDB
+;
+INSERT INTO `core_store_group` (`group_id`, `website_id`, `name`, `root_category_id`, `default_store_id`) VALUES (0, 0, 'Default', 0, 0);
+INSERT INTO `core_store_group` (`group_id`, `website_id`, `name`, `root_category_id`, `default_store_id`) VALUES (1, 1, 'First Main Store', 2, 1);
+
+DROP TABLE IF EXISTS `core_store`;
+CREATE TABLE `core_store` (
+ `store_id` SMALLINT(5) UNSIGNED COMMENT 'Store Id',
+ `code` VARCHAR(32) NULL DEFAULT NULL COMMENT 'Code',
+ `website_id` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Website Id',
+ `group_id` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Group Id',
+ `name` VARCHAR(255) NOT NULL COMMENT 'Store Name',
+ `sort_order` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Store Sort Order',
+ `is_active` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Store Activity',
+ PRIMARY KEY (`store_id`),
+ UNIQUE INDEX `UNQ_CORE_STORE_CODE` (`code`),
+ INDEX `IDX_CORE_STORE_WEBSITE_ID` (`website_id`),
+ INDEX `IDX_CORE_STORE_IS_ACTIVE_SORT_ORDER` (`is_active`, `sort_order`),
+ INDEX `IDX_CORE_STORE_GROUP_ID` (`group_id`),
+ CONSTRAINT `FK_CORE_STORE_GROUP_ID_CORE_STORE_GROUP_GROUP_ID` FOREIGN KEY (`group_id`) REFERENCES `core_store_group` (`group_id`) ON UPDATE CASCADE ON DELETE CASCADE,
+ CONSTRAINT `FK_CORE_STORE_WEBSITE_ID_CORE_WEBSITE_WEBSITE_ID` FOREIGN KEY (`website_id`) REFERENCES `core_website` (`website_id`) ON UPDATE CASCADE ON DELETE CASCADE
+)
+COMMENT='Stores'
+COLLATE='utf8_general_ci'
+ENGINE=InnoDB
+;
+
+/*!40000 ALTER TABLE `core_store` DISABLE KEYS */;
+LOCK TABLES `core_store` WRITE;
+/*!40000 ALTER TABLE `core_store` DISABLE KEYS */;
+INSERT INTO `core_store` VALUES
+(1,'admin',0,0,'Admin',0,1),
+(2,'default',1,1,'Default Store View',0,1);
+/*!40000 ALTER TABLE `core_store` ENABLE KEYS */;
+UNLOCK TABLES;
+/*!40000 ALTER TABLE `core_store` ENABLE KEYS */;
+
+
+DROP TABLE IF EXISTS `core_url_rewrite`;
+CREATE TABLE `core_url_rewrite` (
+ `url_rewrite_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Rewrite Id',
+ `store_id` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Store Id',
+ `category_id` INT(10) UNSIGNED NULL DEFAULT NULL COMMENT 'Category Id',
+ `product_id` INT(10) UNSIGNED NULL DEFAULT NULL COMMENT 'Product Id',
+ `id_path` VARCHAR(255) NULL DEFAULT NULL COMMENT 'Id Path',
+ `request_path` VARCHAR(255) NULL DEFAULT NULL COMMENT 'Request Path',
+ `target_path` VARCHAR(255) NULL DEFAULT NULL COMMENT 'Target Path',
+ `is_system` SMALLINT(5) UNSIGNED NULL DEFAULT '1' COMMENT 'Defines is Rewrite System',
+ `options` VARCHAR(255) NULL DEFAULT NULL COMMENT 'Options',
+ `description` VARCHAR(255) NULL DEFAULT NULL COMMENT 'Description',
+ PRIMARY KEY (`url_rewrite_id`),
+ UNIQUE INDEX `UNQ_CORE_URL_REWRITE_REQUEST_PATH_STORE_ID` (`request_path`, `store_id`),
+ UNIQUE INDEX `UNQ_CORE_URL_REWRITE_ID_PATH_IS_SYSTEM_STORE_ID` (`id_path`, `is_system`, `store_id`),
+ INDEX `IDX_CORE_URL_REWRITE_TARGET_PATH_STORE_ID` (`target_path`, `store_id`),
+ INDEX `IDX_CORE_URL_REWRITE_ID_PATH` (`id_path`),
+ INDEX `IDX_CORE_URL_REWRITE_STORE_ID` (`store_id`),
+ INDEX `FK_CORE_URL_REWRITE_PRODUCT_ID_CATALOG_PRODUCT_ENTITY_ENTITY_ID` (`product_id`),
+ INDEX `FK_CORE_URL_REWRITE_CTGR_ID_CAT_CTGR_ENTT_ENTT_ID` (`category_id`),
+ CONSTRAINT `FK_CORE_URL_REWRITE_CTGR_ID_CAT_CTGR_ENTT_ENTT_ID` FOREIGN KEY (`category_id`) REFERENCES `catalog_category_entity` (`entity_id`) ON UPDATE CASCADE ON DELETE CASCADE,
+ CONSTRAINT `FK_CORE_URL_REWRITE_PRODUCT_ID_CATALOG_PRODUCT_ENTITY_ENTITY_ID` FOREIGN KEY (`product_id`) REFERENCES `catalog_product_entity` (`entity_id`) ON UPDATE CASCADE ON DELETE CASCADE,
+ CONSTRAINT `FK_CORE_URL_REWRITE_STORE_ID_CORE_STORE_STORE_ID` FOREIGN KEY (`store_id`) REFERENCES `core_store` (`store_id`) ON UPDATE CASCADE ON DELETE CASCADE
+)
+COMMENT='Url Rewrites'
+COLLATE='utf8_general_ci'
+ENGINE=InnoDB
+;
+INSERT INTO `core_url_rewrite` (`url_rewrite_id`, `store_id`, `category_id`, `product_id`, `id_path`, `request_path`, `target_path`, `is_system`, `options`, `description`) VALUES (3, 1, 3, 1, 'product/1/3', NULL, 'catalog/product/view/id/1/category/3', 1, '', NULL);
+INSERT INTO `core_url_rewrite` (`url_rewrite_id`, `store_id`, `category_id`, `product_id`, `id_path`, `request_path`, `target_path`, `is_system`, `options`, `description`) VALUES (4, 1, 1, 1, 'product/1', NULL, 'catalog/product/view/id/1', 1, '', NULL);
+INSERT INTO `core_url_rewrite` (`url_rewrite_id`, `store_id`, `category_id`, `product_id`, `id_path`, `request_path`, `target_path`, `is_system`, `options`, `description`) VALUES (5, 2, 3, 1, 'product/1/3', NULL, 'catalog/product/view/id/1/category/3', 1, '', NULL);
+INSERT INTO `core_url_rewrite` (`url_rewrite_id`, `store_id`, `category_id`, `product_id`, `id_path`, `request_path`, `target_path`, `is_system`, `options`, `description`) VALUES (6, 2, 1, 1, 'product/1', NULL, 'catalog/product/view/id/1', 1, '', NULL);
+INSERT INTO `core_url_rewrite` (`url_rewrite_id`, `store_id`, `category_id`, `product_id`, `id_path`, `request_path`, `target_path`, `is_system`, `options`, `description`) VALUES (7, 1, 3, 2, 'product/2/3', 'newcat/virtual-product.html', 'catalog/product/view/id/2/category/3', 1, '', NULL);
+INSERT INTO `core_url_rewrite` (`url_rewrite_id`, `store_id`, `category_id`, `product_id`, `id_path`, `request_path`, `target_path`, `is_system`, `options`, `description`) VALUES (8, 1, 1, 2, 'product/2', 'virtual-product.html', 'catalog/product/view/id/2', 1, '', NULL);
+INSERT INTO `core_url_rewrite` (`url_rewrite_id`, `store_id`, `category_id`, `product_id`, `id_path`, `request_path`, `target_path`, `is_system`, `options`, `description`) VALUES (9, 2, 3, 2, 'product/2/3', 'newcat/virtual-product.html', 'catalog/product/view/id/2/category/3', 1, '', NULL);
+INSERT INTO `core_url_rewrite` (`url_rewrite_id`, `store_id`, `category_id`, `product_id`, `id_path`, `request_path`, `target_path`, `is_system`, `options`, `description`) VALUES (10, 2, 1, 2, 'product/2', 'virtual-product.html', 'catalog/product/view/id/2', 1, '', NULL);
+
+DROP TABLE IF EXISTS `cms_page`;
+CREATE TABLE `cms_page` (
+ `page_id` SMALLINT(6) NOT NULL AUTO_INCREMENT COMMENT 'Page ID',
+ `title` VARCHAR(255) NULL DEFAULT NULL COMMENT 'Page Title',
+ `root_template` VARCHAR(255) NULL DEFAULT NULL COMMENT 'Page Template',
+ `meta_keywords` TEXT NULL COMMENT 'Page Meta Keywords',
+ `meta_description` TEXT NULL COMMENT 'Page Meta Description',
+ `identifier` VARCHAR(100) NOT NULL COMMENT 'Page String Identifier',
+ `content_heading` VARCHAR(255) NULL DEFAULT NULL COMMENT 'Page Content Heading',
+ `content` MEDIUMTEXT NULL COMMENT 'Page Content',
+ `creation_time` TIMESTAMP NULL DEFAULT NULL COMMENT 'Page Creation Time',
+ `update_time` TIMESTAMP NULL DEFAULT NULL COMMENT 'Page Modification Time',
+ `is_active` SMALLINT(6) NOT NULL DEFAULT '1' COMMENT 'Is Page Active',
+ `sort_order` SMALLINT(6) NOT NULL DEFAULT '0' COMMENT 'Page Sort Order',
+ `layout_update_xml` TEXT NULL COMMENT 'Page Layout Update Content',
+ `custom_theme` VARCHAR(100) NULL DEFAULT NULL COMMENT 'Page Custom Theme',
+ `custom_root_template` VARCHAR(255) NULL DEFAULT NULL COMMENT 'Page Custom Template',
+ `custom_layout_update_xml` TEXT NULL COMMENT 'Page Custom Layout Update Content',
+ `custom_theme_from` DATE NULL DEFAULT NULL COMMENT 'Page Custom Theme Active From Date',
+ `custom_theme_to` DATE NULL DEFAULT NULL COMMENT 'Page Custom Theme Active To Date',
+ `published_revision_id` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Published Revision Id',
+ `website_root` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '1' COMMENT 'Website Root',
+ `under_version_control` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Under Version Control Flag',
+ PRIMARY KEY (`page_id`),
+ INDEX `IDX_CMS_PAGE_IDENTIFIER` (`identifier`)
+)
+COMMENT='CMS Page Table'
+COLLATE='utf8_general_ci'
+ENGINE=InnoDB
+;
+INSERT INTO `cms_page` VALUES
+(1, '404 Not Found 1', 'two_columns_right', 'Page keywords', 'Page description', 'no-route', '', 'We’re sorry, the page you’re looking for can not be found.
\n\n
\n - If you typed the URL directly, please make sure the spelling is correct.
\n - If you clicked on a link to get here, we must have moved the content.
Please try our store search box above to search for an item. \n - If you are not sure how you got here, go back to the previous page or return to our store homepage.
\n
\n
\n\n', '2007-06-20 18:38:32', '2007-08-26 19:11:13', 1, 0, NULL, NULL, '', NULL, NULL, NULL, 1, 1, 0);
+
+DROP TABLE IF EXISTS `cms_page_store`;
+CREATE TABLE `cms_page_store` (
+ `page_id` SMALLINT(6) NOT NULL COMMENT 'Page ID',
+ `store_id` SMALLINT(5) UNSIGNED NOT NULL COMMENT 'Store ID',
+ PRIMARY KEY (`page_id`, `store_id`),
+ INDEX `IDX_CMS_PAGE_STORE_STORE_ID` (`store_id`),
+ CONSTRAINT `FK_CMS_PAGE_STORE_PAGE_ID_CMS_PAGE_PAGE_ID` FOREIGN KEY (`page_id`) REFERENCES `cms_page` (`page_id`) ON UPDATE CASCADE ON DELETE CASCADE,
+ CONSTRAINT `FK_CMS_PAGE_STORE_STORE_ID_CORE_STORE_STORE_ID` FOREIGN KEY (`store_id`) REFERENCES `core_store` (`store_id`) ON UPDATE CASCADE ON DELETE CASCADE
+)
+COMMENT='CMS Page To Store Linkage Table'
+COLLATE='utf8_general_ci'
+ENGINE=InnoDB
+;
+INSERT INTO `cms_page_store` VALUES (1, 1);
\ No newline at end of file
diff --git a/tests/integration/testsuite/Migration/Step/SalesIncrement/DataTest.php b/tests/integration/testsuite/Migration/Step/SalesIncrement/DataTest.php
new file mode 100644
index 000000000..f1cd05533
--- /dev/null
+++ b/tests/integration/testsuite/Migration/Step/SalesIncrement/DataTest.php
@@ -0,0 +1,232 @@
+ 1,
+ 'entity_type' => 'order',
+ 'store_id' => 0,
+ 'sequence_table' => 'sequence_order_0',
+ ],
+ [
+ 'meta_id' => 2,
+ 'entity_type' => 'order',
+ 'store_id' => 1,
+ 'sequence_table' => 'sequence_order_1',
+ ],
+ [
+ 'meta_id' => 3,
+ 'entity_type' => 'invoice',
+ 'store_id' => 0,
+ 'sequence_table' => 'sequence_invoice_0',
+ ],
+ [
+ 'meta_id' => 4,
+ 'entity_type' => 'invoice',
+ 'store_id' => 1,
+ 'sequence_table' => 'sequence_invoice_1',
+ ],
+ [
+ 'meta_id' => 5,
+ 'entity_type' => 'creditmemo',
+ 'store_id' => 0,
+ 'sequence_table' => 'sequence_creditmemo_0',
+ ],
+ [
+ 'meta_id' => 6,
+ 'entity_type' => 'creditmemo',
+ 'store_id' => 1,
+ 'sequence_table' => 'sequence_creditmemo_1',
+ ],
+ [
+ 'meta_id' => 7,
+ 'entity_type' => 'shipment',
+ 'store_id' => 0,
+ 'sequence_table' => 'sequence_shipment_0',
+ ],
+ [
+ 'meta_id' => 8,
+ 'entity_type' => 'shipment',
+ 'store_id' => 1,
+ 'sequence_table' => 'sequence_shipment_1',
+ ],
+ [
+ 'meta_id' => 9,
+ 'entity_type' => 'rma_item',
+ 'store_id' => 0,
+ 'sequence_table' => 'sequence_rma_item_0',
+ ],
+ [
+ 'meta_id' => 10,
+ 'entity_type' => 'rma_item',
+ 'store_id' => 1,
+ 'sequence_table' => 'sequence_rma_item_1',
+ ]
+ ];
+
+ /**
+ * @var array
+ */
+ private $salesSequenceProfile = [
+ [
+ 'profile_id' => 1,
+ 'meta_id' => 1,
+ 'prefix' => '',
+ 'suffix' => '',
+ 'start_value' => 1,
+ 'step' => 1,
+ 'max_value' => 4294967295,
+ 'warning_value' => 4294966295,
+ 'is_active' => 1,
+ ],
+ [
+ 'profile_id' => 2,
+ 'meta_id' => 2,
+ 'prefix' => '1',
+ 'suffix' => '',
+ 'start_value' => 1,
+ 'step' => 1,
+ 'max_value' => 4294967295,
+ 'warning_value' => 4294966295,
+ 'is_active' => 1,
+ ],
+ [
+ 'profile_id' => 3,
+ 'meta_id' => 3,
+ 'prefix' => '',
+ 'suffix' => '',
+ 'start_value' => 1,
+ 'step' => 1,
+ 'max_value' => 4294967295,
+ 'warning_value' => 4294966295,
+ 'is_active' => 1,
+ ],
+ [
+ 'profile_id' => 4,
+ 'meta_id' => 4,
+ 'prefix' => '1',
+ 'suffix' => '',
+ 'start_value' => 1,
+ 'step' => 1,
+ 'max_value' => 4294967295,
+ 'warning_value' => 4294966295,
+ 'is_active' => 1,
+ ],
+ [
+ 'profile_id' => 5,
+ 'meta_id' => 5,
+ 'prefix' => '',
+ 'suffix' => '',
+ 'start_value' => 1,
+ 'step' => 1,
+ 'max_value' => 4294967295,
+ 'warning_value' => 4294966295,
+ 'is_active' => 1,
+ ],
+ [
+ 'profile_id' => 6,
+ 'meta_id' => 6,
+ 'prefix' => '1',
+ 'suffix' => '',
+ 'start_value' => 1,
+ 'step' => 1,
+ 'max_value' => 4294967295,
+ 'warning_value' => 4294966295,
+ 'is_active' => 1,
+ ],
+ [
+ 'profile_id' => 7,
+ 'meta_id' => 7,
+ 'prefix' => '',
+ 'suffix' => '',
+ 'start_value' => 1,
+ 'step' => 1,
+ 'max_value' => 4294967295,
+ 'warning_value' => 4294966295,
+ 'is_active' => 1,
+ ],
+ [
+ 'profile_id' => 8,
+ 'meta_id' => 8,
+ 'prefix' => '1',
+ 'suffix' => '',
+ 'start_value' => 1,
+ 'step' => 1,
+ 'max_value' => 4294967295,
+ 'warning_value' => 4294966295,
+ 'is_active' => 1,
+ ],
+ [
+ 'profile_id' => 9,
+ 'meta_id' => 9,
+ 'prefix' => '',
+ 'suffix' => '',
+ 'start_value' => 1,
+ 'step' => 1,
+ 'max_value' => 4294967295,
+ 'warning_value' => 4294966295,
+ 'is_active' => 1,
+ ],
+ [
+ 'profile_id' => 10,
+ 'meta_id' => 10,
+ 'prefix' => '1',
+ 'suffix' => '',
+ 'start_value' => 1,
+ 'step' => 1,
+ 'max_value' => 4294967295,
+ 'warning_value' => 4294966295,
+ 'is_active' => 1,
+ ]
+ ];
+
+ /**
+ * @throws \Migration\Exception
+ * @return void
+ */
+ public function testPerform()
+ {
+ $helper = \Migration\TestFramework\Helper::getInstance();
+ $objectManager = $helper->getObjectManager();
+ $objectManager->get('\Migration\Config')
+ ->init(dirname(__DIR__) . '/../_files/' . $helper->getFixturePrefix() . 'config.xml');
+ $logManager = $objectManager->create('\Migration\Logger\Manager');
+ $logger = $objectManager->create('\Migration\Logger\Logger');
+ $config = $objectManager->get('\Migration\Config');
+ $helper = $objectManager->get('\Migration\Step\SalesIncrement\Helper');
+ $destination = $objectManager->get('\Migration\ResourceModel\Destination');
+ /** @var \Migration\Logger\Manager $logManager */
+ $logManager->process(\Migration\Logger\Manager::LOG_LEVEL_ERROR);
+ \Migration\Logger\Logger::clearMessages();
+ /** @var \Migration\Step\SalesIncrement\Data $salesIncrement */
+ $salesIncrement = $objectManager->create(
+ '\Migration\Step\SalesIncrement\Data',
+ [
+ 'logger' => $logger,
+ 'config' => $config,
+ 'helper' => $helper
+ ]
+ );
+ ob_start();
+ $salesIncrement->perform();
+ ob_end_clean();
+
+ $this->assertEquals($this->salesSequenceMeta, $destination->getRecords('sales_sequence_meta', 0));
+ $this->assertEquals($this->salesSequenceProfile, $destination->getRecords('sales_sequence_profile', 0));
+ $logOutput = \Migration\Logger\Logger::getMessages();
+ $this->assertFalse(isset($logOutput[\Monolog\Logger::ERROR]));
+ }
+}
diff --git a/tests/integration/testsuite/Migration/Step/UrlRewrite/Version11410to2000Test.php b/tests/integration/testsuite/Migration/Step/UrlRewrite/Version11410to2000Test.php
index c41cbcf78..9393d74b5 100644
--- a/tests/integration/testsuite/Migration/Step/UrlRewrite/Version11410to2000Test.php
+++ b/tests/integration/testsuite/Migration/Step/UrlRewrite/Version11410to2000Test.php
@@ -8,7 +8,7 @@
/**
* UrlRewrite step test class
- * @dbFixture url_rewrite
+ * @dbFixture url_rewrite_11410
*/
class Version11410to2000Test extends \PHPUnit_Framework_TestCase
{
diff --git a/tests/integration/testsuite/Migration/Step/UrlRewrite/Version191to2000Test.php b/tests/integration/testsuite/Migration/Step/UrlRewrite/Version191to2000Test.php
new file mode 100644
index 000000000..5ae4dae7f
--- /dev/null
+++ b/tests/integration/testsuite/Migration/Step/UrlRewrite/Version191to2000Test.php
@@ -0,0 +1,109 @@
+objectManager = $helper->getObjectManager();
+ $this->objectManager->get('\Migration\Config')
+ ->init(dirname(__DIR__) . '/../_files/' . $helper->getFixturePrefix() . 'config.xml');
+ $this->tableName = 'url_rewrite_m2' . md5('url_rewrite_m2');
+ $logManager = $this->objectManager->create('\Migration\Logger\Manager');
+ $this->logger = $this->objectManager->create('\Migration\Logger\Logger');
+ $this->logger->pushHandler($this->objectManager->create('\Migration\Logger\ConsoleHandler'));
+ $this->config = $this->objectManager->get('\Migration\Config');
+ /** @var \Migration\Logger\Manager $logManager */
+ $logManager->process(\Migration\Logger\Manager::LOG_LEVEL_ERROR);
+ \Migration\Logger\Logger::clearMessages();
+ }
+
+ /**
+ * @return void
+ */
+ public function testIntegrity()
+ {
+ $urlRewrite = $this->objectManager->create(
+ '\Migration\Step\UrlRewrite\Version191to2000',
+ [
+ 'logger' => $this->logger,
+ 'config' => $this->config,
+ 'stage' => 'integrity'
+ ]
+ );
+ ob_start();
+ $result = $urlRewrite->perform();
+ ob_end_clean();
+ $this->assertTrue($result);
+ }
+
+ /**
+ * @return void
+ */
+ public function testData()
+ {
+ $urlRewrite = $this->objectManager->create(
+ '\Migration\Step\UrlRewrite\Version191to2000',
+ [
+ 'logger' => $this->logger,
+ 'config' => $this->config,
+ 'stage' => 'data'
+ ]
+ );
+ /** @var \Migration\ResourceModel\Destination $destination */
+ $destination = $this->objectManager->get('\Migration\ResourceModel\Destination');
+ ob_start();
+ $urlRewrite->perform();
+ ob_end_clean();
+
+ $logOutput = \Migration\Logger\Logger::getMessages();
+ $this->assertTrue(empty($logOutput[\Monolog\Logger::ERROR]));
+ $this->assertEquals(8, $destination->getRecordsCount('url_rewrite'));
+ $this->assertEquals(4, $destination->getRecordsCount('catalog_url_rewrite_product_category'));
+
+ $urlRewrite = $this->objectManager->create(
+ '\Migration\Step\UrlRewrite\Version191to2000',
+ [
+ 'logger' => $this->logger,
+ 'config' => $this->config,
+ 'stage' => 'volume'
+ ]
+ );
+ $result = $urlRewrite->perform();
+ $this->assertTrue($result);
+ }
+}
diff --git a/tests/unit/testsuite/Migration/Handler/EavAttributeGroup/SetGroupCodeTest.php b/tests/unit/testsuite/Migration/Handler/EavAttributeGroup/SetGroupCodeTest.php
index 56c38d4f8..5d16f3077 100644
--- a/tests/unit/testsuite/Migration/Handler/EavAttributeGroup/SetGroupCodeTest.php
+++ b/tests/unit/testsuite/Migration/Handler/EavAttributeGroup/SetGroupCodeTest.php
@@ -7,6 +7,7 @@
use Migration\ResourceModel\Record;
use Migration\Step\DatabaseStage;
+use Migration\Model\Eav\AttributeGroupNameToCodeMap;
/**
* Class SetGroupCodeTest
@@ -18,6 +19,8 @@ class SetGroupCodeTest extends \PHPUnit_Framework_TestCase
*/
public function testHandle()
{
+ $groupName = 'Migration General';
+ $groupCode = 'migration-general';
/** @var \Migration\ResourceModel\Record|\PHPUnit_Framework_MockObject_MockObject $recordToHandle */
$recordToHandle = $this->getMockBuilder('Migration\ResourceModel\Record')
->setMethods(['getValue', 'setValue', 'getFields'])
@@ -28,12 +31,23 @@ public function testHandle()
->disableOriginalConstructor()
->getMock();
+ /** @var AttributeGroupNameToCodeMap $attributeGroupNameToCodeMap|\PHPUnit_Framework_MockObject_MockObject */
+ $attributeGroupNameToCodeMap = $this->getMockBuilder('Migration\Model\Eav\AttributeGroupNameToCodeMap')
+ ->setMethods(['getGroupCodeMap'])
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $attributeGroupNameToCodeMap->expects($this->once())
+ ->method('getGroupCodeMap')
+ ->with($groupName)
+ ->willReturn($groupCode);
+
$fieldName = 'fieldname';
$recordToHandle->expects($this->once())->method('getFields')->will($this->returnValue([$fieldName]));
$recordToHandle->expects($this->at(1))->method('getValue')->with('attribute_set_id')->willReturn(1);
$recordToHandle->expects($this->at(2))->method('getValue')->with('attribute_group_name')
- ->willReturn('Migration General');
- $recordToHandle->expects($this->once())->method('setValue')->with($fieldName, 'product-details');
+ ->willReturn($groupName);
+ $recordToHandle->expects($this->once())->method('setValue')->with($fieldName, $groupCode);
$config = $this->getMockBuilder('Migration\Config')
->disableOriginalConstructor()->setMethods(['getSource'])->getMock();
@@ -57,7 +71,7 @@ public function testHandle()
$adapter->expects($this->once())->method('getSelect')->willReturn($select);
$adapter->expects($this->once())->method('fetchCol')->willReturn([1=>0, 2=>1]);
- $handler = new SetGroupCode($config, $source);
+ $handler = new SetGroupCode($config, $source, $attributeGroupNameToCodeMap);
$handler->setField($fieldName);
$handler->handle($recordToHandle, $oppositeRecord);
}
diff --git a/tests/unit/testsuite/Migration/Handler/GetEventStatusTest.php b/tests/unit/testsuite/Migration/Handler/GetEventStatusTest.php
new file mode 100644
index 000000000..44a985b1a
--- /dev/null
+++ b/tests/unit/testsuite/Migration/Handler/GetEventStatusTest.php
@@ -0,0 +1,70 @@
+getMockBuilder('Migration\ResourceModel\Record')
+ ->setMethods(['setValue', 'getValue', 'getFields'])
+ ->getMock();
+ $record->expects($this->any())->method('getFields')->willReturn(['status']);
+ $record->expects($this->any())->method('getValue')->willReturnMap(
+ [
+ ['date_start', $dateStart],
+ ['date_end', $dateEnd]
+ ]
+ );
+ $record->expects($this->once())->method('setValue')->with('status', $status);
+
+ $record2 = $this->getMockBuilder('Migration\ResourceModel\Record')->disableOriginalConstructor()->getMock();
+
+ $handler = new GetEventStatus();
+ $handler->setField('status');
+ $handler->handle($record, $record2);
+ }
+
+ /**
+ * @return array
+ */
+ public function eventDatesDataProvider()
+ {
+ return [
+ 'closed' => [
+ 'date_start' => date('Y-m-d H:i:s', strtotime('-5 days')),
+ 'date_end' => date('Y-m-d H:i:s', strtotime('-2 days')),
+ 'status' => GetEventStatus::EVENT_CLOSED
+ ],
+ 'open' => [
+ 'date_start' => date('Y-m-d H:i:s', strtotime('-1 days')),
+ 'date_end' => date('Y-m-d H:i:s', strtotime('+2 days')),
+ 'status' => GetEventStatus::EVENT_OPEN
+
+ ],
+ 'upcoming' => [
+ 'date_start' => date('Y-m-d H:i:s', strtotime('+2 days')),
+ 'date_end' => date('Y-m-d H:i:s', strtotime('+5 days')),
+ 'status' => GetEventStatus::EVENT_UPCOMING
+ ]
+ ];
+
+ }
+}
diff --git a/tests/unit/testsuite/Migration/Model/Eav/AttributeGroupNameToCodeMapTest.php b/tests/unit/testsuite/Migration/Model/Eav/AttributeGroupNameToCodeMapTest.php
new file mode 100644
index 000000000..55111b51c
--- /dev/null
+++ b/tests/unit/testsuite/Migration/Model/Eav/AttributeGroupNameToCodeMapTest.php
@@ -0,0 +1,53 @@
+model = $objectHelper->getObject('\Migration\Model\Eav\AttributeGroupNameToCodeMap');
+ }
+
+ /**
+ * @dataProvider getGroupsData()
+ * @param string $groupName
+ * @param string $groupCode
+ * @return void
+ */
+ public function testGetGroupCodeMap($groupName, $groupCode)
+ {
+ $result = $this->model->getGroupCodeMap($groupName);
+ $this->assertEquals($result, $groupCode);
+ }
+
+ /**
+ * @return array
+ */
+ public function getGroupsData()
+ {
+ return [
+ ['Migration_General', 'product-details'],
+ ['Migration_Prices', 'advanced-pricing'],
+ ['Migration_Design', 'design'],
+ ['Migration_Something', 'migration-something'],
+ ];
+ }
+}
diff --git a/tests/unit/testsuite/Migration/ResourceModel/AbstractResourceTest.php b/tests/unit/testsuite/Migration/ResourceModel/AbstractResourceTest.php
index a85f59b91..a9f595fd6 100644
--- a/tests/unit/testsuite/Migration/ResourceModel/AbstractResourceTest.php
+++ b/tests/unit/testsuite/Migration/ResourceModel/AbstractResourceTest.php
@@ -76,6 +76,9 @@ protected function setUp()
'dbname' => 'dbname',
'username' => 'uname',
'password' => 'upass',
+ ],
+ 'init_select_parts' => [
+ 'disable_staging_preview' => true
]
]];
$this->config = $this->getMock(
@@ -85,12 +88,12 @@ protected function setUp()
'',
false
);
- $this->config->expects($this->once())
+ $this->config->expects($this->any())
->method('getDestination')
- ->will($this->returnValue($destinationConfig));
- $this->config->expects($this->once())
+ ->willReturn($destinationConfig);
+ $this->config->expects($this->any())
->method('getSource')
- ->will($this->returnValue($config));
+ ->willReturn($config);
$this->adapter = $this->getMock(
'\Migration\ResourceModel\Adapter\Mysql',
['insertRecords', 'getRecordsCount', 'getDocumentStructure', 'getDocumentList', 'loadPage'],
@@ -154,10 +157,10 @@ public function testGetDocument($prefix, $optionName)
$structureData = ['id' => 'int'];
$structure = $this->getMock('\Migration\ResourceModel\Structure', [], [], '', false);
$document = $this->getMock('\Migration\ResourceModel\Document', [], [], '', false);
- $this->config->expects($this->any())
- ->method('getOption')
- ->with($optionName)
- ->will($this->returnValue($prefix));
+ $this->config->expects($this->any())->method('getOption')->willReturnMap([
+ ['edition_migrate', 'ce-to-ee'],
+ [$optionName, $prefix]
+ ]);
$this->documentFactory->expects($this->any())
->method('create')
->with($this->equalTo(['structure' => $structure, 'documentName' => $resourceName]))
@@ -194,11 +197,10 @@ public function getDocumentDataSource()
*/
public function testGetWrongDocument()
{
- $prefix = 'prefix_';
- $this->config->expects($this->any())
- ->method('getOption')
- ->with('dest_prefix')
- ->will($this->returnValue($prefix));
+ $this->config->expects($this->any())->method('getOption')->willReturnMap([
+ ['edition_migrate', 'ce-to-ee'],
+ ['dest_prefix', 'prefix_']
+ ]);
$this->adapter->expects($this->any())
->method('getDocumentList')
->willReturn(['document']);
@@ -212,12 +214,11 @@ public function testGetWrongDocument()
public function testGetRecordsCount()
{
$prefix = 'prefix_';
- $this->config->expects($this->any())
- ->method('getOption')
- ->with('dest_prefix')
- ->will($this->returnValue($prefix));
+ $this->config->expects($this->any())->method('getOption')->willReturnMap([
+ ['edition_migrate', 'ce-to-ee'],
+ ['dest_prefix', $prefix]
+ ]);
$resourceName = 'core_config_data';
-
$this->adapter->expects($this->any())
->method('getRecordsCount')
->with($prefix . $resourceName)
@@ -233,8 +234,11 @@ public function testGetRecords()
{
$resourceName = 'core_config_data';
$pageNumber = 2;
- $this->config->expects($this->at(0))->method('getOption')->with('bulk_size')->will($this->returnValue(100));
- $this->config->expects($this->at(1))->method('getOption')->with('dest_prefix')->will($this->returnValue(100));
+ $this->config->expects($this->any())->method('getOption')->willReturnMap([
+ ['edition_migrate', 'ce-to-ee'],
+ ['bulk_size', 100],
+ ['dest_prefix', 100],
+ ]);
$this->adapter->expects($this->once())->method('loadPage');
$this->resourceDestination->getRecords($resourceName, $pageNumber);
}
@@ -244,6 +248,7 @@ public function testGetRecords()
*/
public function testGetAdapter()
{
+ $this->config->expects($this->once())->method('getOption')->with('edition_migrate')->willReturn('ce-to-ee');
$this->assertSame($this->adapter, $this->resourceDestination->getAdapter());
}
}
diff --git a/tests/unit/testsuite/Migration/ResourceModel/DestinationTest.php b/tests/unit/testsuite/Migration/ResourceModel/DestinationTest.php
index 94ded72b8..3d0e8e3ad 100644
--- a/tests/unit/testsuite/Migration/ResourceModel/DestinationTest.php
+++ b/tests/unit/testsuite/Migration/ResourceModel/DestinationTest.php
@@ -66,7 +66,10 @@ protected function setUp()
'host' => 'localhost',
'dbname' => 'dbname',
'username' => 'uname',
- 'password' => 'upass',
+ 'password' => 'upass'
+ ],
+ 'init_select_parts' => [
+ 'disable_staging_preview' => true
]
]];
$this->config = $this->getMock('\Migration\Config', ['getOption', 'getDestination'], [], '', false);
@@ -107,13 +110,11 @@ public function testSaveRecords($prefix)
{
$resourceName = 'core_config_data';
- $this->config->expects($this->any())
- ->method('getOption')
- ->willReturnMap([
- ['bulk_size', 3],
- ['dest_prefix', $prefix]
- ]);
-
+ $this->config->expects($this->any())->method('getOption')->willReturnMap([
+ ['edition_migrate', 'ce-to-ee'],
+ ['bulk_size', 3],
+ ['dest_prefix', $prefix]
+ ]);
$this->adapter->expects($this->at(0))
->method('insertRecords')
->with($prefix . $resourceName, [['data' => 'value1'], ['data' => 'value2'], ['data' => 'value3']])
@@ -167,8 +168,10 @@ public function testClearDocument()
{
$docName = 'somename';
$this->adapter->expects($this->once())->method('deleteAllRecords')->with('pfx_' . $docName);
- $this->config->expects($this->once())->method('getOption')->with('dest_prefix')
- ->will($this->returnValue('pfx_'));
+ $this->config->expects($this->any())->method('getOption')->willReturnMap([
+ ['edition_migrate', 'ce-to-ee'],
+ ['dest_prefix', 'pfx_']
+ ]);
$this->resourceDestination->clearDocument($docName);
}
@@ -179,8 +182,10 @@ public function testBackupDocument()
{
$docName = 'somename';
$this->adapter->expects($this->once())->method('backupDocument')->with('pfx_' . $docName);
- $this->config->expects($this->once())->method('getOption')->with('dest_prefix')
- ->will($this->returnValue('pfx_'));
+ $this->config->expects($this->any())->method('getOption')->willReturnMap([
+ ['edition_migrate', 'ce-to-ee'],
+ ['dest_prefix', 'pfx_']
+ ]);
$this->resourceDestination->backupDocument($docName);
}
@@ -191,8 +196,10 @@ public function testRollbackDocument()
{
$docName = 'somename';
$this->adapter->expects($this->once())->method('rollbackDocument')->with('pfx_' . $docName);
- $this->config->expects($this->once())->method('getOption')->with('dest_prefix')
- ->will($this->returnValue('pfx_'));
+ $this->config->expects($this->any())->method('getOption')->willReturnMap([
+ ['edition_migrate', 'ce-to-ee'],
+ ['dest_prefix', 'pfx_']
+ ]);
$this->resourceDestination->rollbackDocument($docName);
}
@@ -203,8 +210,10 @@ public function testDeleteDocumentBackup()
{
$docName = 'somename';
$this->adapter->expects($this->once())->method('deleteBackup')->with('pfx_' . $docName);
- $this->config->expects($this->once())->method('getOption')->with('dest_prefix')
- ->will($this->returnValue('pfx_'));
+ $this->config->expects($this->any())->method('getOption')->willReturnMap([
+ ['edition_migrate', 'ce-to-ee'],
+ ['dest_prefix', 'pfx_']
+ ]);
$this->resourceDestination->deleteDocumentBackup($docName);
}
}
diff --git a/tests/unit/testsuite/Migration/ResourceModel/SourceTest.php b/tests/unit/testsuite/Migration/ResourceModel/SourceTest.php
index 9ea5adcdc..995bd1f7c 100644
--- a/tests/unit/testsuite/Migration/ResourceModel/SourceTest.php
+++ b/tests/unit/testsuite/Migration/ResourceModel/SourceTest.php
@@ -62,6 +62,9 @@ protected function setUp()
'password' => 'upass',
'dbname' => 'dbname',
'username' => 'uname'
+ ],
+ 'init_select_parts' => [
+ 'disable_staging_preview' => true
]
]];
$this->config = $this->getMock('\Migration\Config', ['getOption', 'getSource'], [], '', false);
@@ -107,10 +110,10 @@ protected function setUp()
*/
public function testLoadPage()
{
- $this->config->expects($this->any())
- ->method('getOption')
- ->with('bulk_size')
- ->will($this->returnValue($this->bulkSize));
+ $this->config->expects($this->any())->method('getOption')->willReturnMap([
+ ['edition_migrate', 'ce-to-ee'],
+ ['bulk_size', $this->bulkSize]
+ ]);
$this->adapter->expects($this->any())->method('loadPage')->with('table', 2)->willReturn(['1', '2']);
$this->assertEquals(['1', '2'], $this->resourceSource->loadPage('table', 2));
}
@@ -122,9 +125,10 @@ public function testCreateDelta()
{
$this->adapter->expects($this->once())->method('createDelta')
->with('spfx_document', 'spfx_m2_cl_document', 'key_field');
- $this->config->expects($this->any())->method('getOption')
- ->with(Source::CONFIG_DOCUMENT_PREFIX)
- ->willReturn('spfx_');
+ $this->config->expects($this->any())->method('getOption')->willReturnMap([
+ ['edition_migrate', 'ce-to-ee'],
+ [Source::CONFIG_DOCUMENT_PREFIX, 'spfx_']
+ ]);
$this->resourceSource->createDelta('document', 'key_field');
}
@@ -135,12 +139,11 @@ public function testGetChangedRecords()
{
$this->adapter->expects($this->once())->method('loadChangedRecords')
->with('document', 'm2_cl_document', 'key_field', 0, 100);
- $this->config->expects($this->any())->method('getOption')->willReturnMap(
- [
- ['source_prefix', ''],
- ['bulk_size', 100]
- ]
- );
+ $this->config->expects($this->any())->method('getOption')->willReturnMap([
+ ['edition_migrate', 'ce-to-ee'],
+ ['source_prefix', ''],
+ ['bulk_size', 100]
+ ]);
$this->resourceSource->getChangedRecords('document', 'key_field');
}
@@ -151,12 +154,11 @@ public function testGetDeletedRecords()
{
$this->adapter->expects($this->once())->method('loadDeletedRecords')
->with('m2_cl_document', 'key_field', 0, 100);
- $this->config->expects($this->any())->method('getOption')->willReturnMap(
- [
- ['source_prefix', ''],
- ['bulk_size', 100]
- ]
- );
+ $this->config->expects($this->any())->method('getOption')->willReturnMap([
+ ['edition_migrate', 'ce-to-ee'],
+ ['source_prefix', ''],
+ ['bulk_size', 100]
+ ]);
$this->resourceSource->getDeletedRecords('document', 'key_field');
}
}
diff --git a/tests/unit/testsuite/Migration/Step/Eav/HelperTest.php b/tests/unit/testsuite/Migration/Step/Eav/HelperTest.php
index 7fd32bd97..3e6c3040e 100644
--- a/tests/unit/testsuite/Migration/Step/Eav/HelperTest.php
+++ b/tests/unit/testsuite/Migration/Step/Eav/HelperTest.php
@@ -46,6 +46,11 @@ class HelperTest extends \PHPUnit_Framework_TestCase
*/
protected $readerGroups;
+ /**
+ * @var \Migration\Reader\Groups|\PHPUnit_Framework_MockObject_MockObject
+ */
+ protected $readerAttributes;
+
/**
* @return void
*/
@@ -72,6 +77,10 @@ public function setUp()
->disableOriginalConstructor()
->setMethods([])
->getMock();
+ $this->readerAttributes = $this->getMockBuilder('\Migration\Reader\Groups')
+ ->disableOriginalConstructor()
+ ->setMethods([])
+ ->getMock();
/** @var \Migration\Reader\GroupsFactory|\PHPUnit_Framework_MockObject_MockObject $groupsFactory */
$groupsFactory = $this->getMockBuilder('\Migration\Reader\GroupsFactory')
->disableOriginalConstructor()
@@ -79,9 +88,12 @@ public function setUp()
->getMock();
$groupsFactory->expects($this->any())
->method('create')
- ->with('eav_document_groups_file')
- ->willReturn($this->readerGroups);
-
+ ->willReturnMap(
+ [
+ ['eav_document_groups_file', $this->readerGroups],
+ ['eav_attribute_groups_file', $this->readerAttributes]
+ ]
+ );
$this->helper = new Helper($mapFactory, $this->source, $this->destination, $this->factory, $groupsFactory);
}
@@ -214,4 +226,33 @@ public function testDeleteBackups()
$this->destination->expects($this->once())->method('deleteDocumentBackup')->with('some_dest_document');
$this->helper->deleteBackups();
}
+
+ /**
+ * @return void
+ */
+ public function testClearIgnoredAttributes()
+ {
+ $allSourceRecords = [
+ 0 => [
+ 'attribute_code' => 'ignored_attribute'
+ ],
+ 1 => [
+ 'attribute_code' => 'attribute_1'
+ ],
+ 2 => [
+ 'attribute_code' => 'attribute_2'
+ ]
+ ];
+ $clearedSourceRecords = [
+ 1 => [
+ 'attribute_code' => 'attribute_1'
+ ],
+ 2 => [
+ 'attribute_code' => 'attribute_2'
+ ]
+ ];
+ $this->readerAttributes->expects($this->once())->method('getGroup')->with('ignore')
+ ->willReturn(['ignored_attribute' => 0]);
+ $this->assertEquals($clearedSourceRecords, $this->helper->clearIgnoredAttributes($allSourceRecords));
+ }
}
diff --git a/tests/unit/testsuite/Migration/Step/Eav/InitialDataTest.php b/tests/unit/testsuite/Migration/Step/Eav/InitialDataTest.php
index 0431baec9..bb3bfc99c 100644
--- a/tests/unit/testsuite/Migration/Step/Eav/InitialDataTest.php
+++ b/tests/unit/testsuite/Migration/Step/Eav/InitialDataTest.php
@@ -101,6 +101,10 @@ public function testInit()
['eav_attribute', ['attribute_id'], $dataAttributes['source']],
['eav_entity_type', [], $eavEntityTypes['source']]
]);
+ $this->helper->expects($this->any())->method('clearIgnored')->willReturnMap([
+ [$dataAttributes['source'], $dataAttributes['source']],
+ [$eavEntityTypes['source'], $eavEntityTypes['source']]
+ ]);
$this->helper->expects($this->any())->method('getDestinationRecords')->willReturnMap(
[
['eav_attribute', ['entity_type_id', 'attribute_code'], $dataAttributes['dest']],
diff --git a/tests/unit/testsuite/Migration/Step/Eav/Integrity/AttributeGroupNamesTest.php b/tests/unit/testsuite/Migration/Step/Eav/Integrity/AttributeGroupNamesTest.php
new file mode 100644
index 000000000..a46934cef
--- /dev/null
+++ b/tests/unit/testsuite/Migration/Step/Eav/Integrity/AttributeGroupNamesTest.php
@@ -0,0 +1,136 @@
+helper = $this->getMockBuilder('\Migration\Step\Eav\Helper')
+ ->disableOriginalConstructor()
+ ->setMethods(['getSourceRecords'])
+ ->getMock();
+
+ $objectHelper = new ObjectManager($this);
+ $groupNameToCodeMap = $objectHelper->getObject('\Migration\Model\Eav\AttributeGroupNameToCodeMap');
+
+ $this->model = $objectHelper->getObject('\Migration\Step\Eav\Integrity\AttributeGroupNames', [
+ 'helper' => $this->helper,
+ 'groupNameToCodeMap' => $groupNameToCodeMap
+ ]);
+ }
+
+ /**
+ * @dataProvider getFixtureData()
+ * @param array $sourceData
+ * @param int $errorsCount
+ * @return void
+ */
+ public function testCheckAttributeGroupNames($sourceData, $errorsCount)
+ {
+ $this->helper->expects($this->any())->method('getSourceRecords')->willReturnMap([
+ ['eav_attribute_group', ['attribute_group_id'], $sourceData['eav_attribute_group']],
+ ['eav_entity_type', ['entity_type_code'], $sourceData['eav_entity_type']],
+ ['eav_attribute_set', ['attribute_set_id'], $sourceData['eav_attribute_set']]
+ ]);
+
+ $result = $this->model->checkAttributeGroupNames();
+ if (array_key_exists(MapInterface::TYPE_SOURCE, $result)) {
+ $result = $result[MapInterface::TYPE_SOURCE];
+ }
+
+ $this->assertCount($errorsCount, $result);
+ }
+
+ /**
+ * @return array
+ */
+ public function getFixtureData()
+ {
+ return [
+ [
+ [
+ 'eav_attribute_group' => [
+ 7 => ['attribute_set_id' => 4, 'attribute_group_name' => 'General'],
+ 8 => ['attribute_set_id' => 4, 'attribute_group_name' => 'Prices'],
+ 11 => ['attribute_set_id' => 4, 'attribute_group_name' => 'Design']
+ ],
+ 'eav_entity_type' => [
+ 'catalog_product' => ['entity_type_id' => 4]
+ ],
+ 'eav_attribute_set' => [
+ 3 => ['attribute_set_id' => 3, 'entity_type_id' => 3, 'attribute_set_name' => 'Default'],
+ 4 => ['attribute_set_id' => 4, 'entity_type_id' => 4, 'attribute_set_name' => 'Default']
+ ]
+ ],
+ 0
+ ], [
+ [
+ 'eav_attribute_group' => [
+ 5 => ['attribute_set_id' => 2, 'attribute_group_name' => 'Prices'],
+ 7 => ['attribute_set_id' => 3, 'attribute_group_name' => 'General'],
+ 8 => ['attribute_set_id' => 3, 'attribute_group_name' => 'Prices'],
+ 11 => ['attribute_set_id' => 3, 'attribute_group_name' => 'Design'],
+ 12 => ['attribute_set_id' => 4, 'attribute_group_name' => 'General']
+ ],
+ 'eav_entity_type' => [
+ 'catalog_product' => ['entity_type_id' => 4]
+ ],
+ 'eav_attribute_set' => [
+ 1 => ['attribute_set_id' => 1, 'entity_type_id' => 3, 'attribute_set_name' => 'Default'],
+ 2 => ['attribute_set_id' => 2, 'entity_type_id' => 4, 'attribute_set_name' => 'Default'],
+ 3 => ['attribute_set_id' => 3, 'entity_type_id' => 4, 'attribute_set_name' => 'Default_2'],
+ 4 => ['attribute_set_id' => 4, 'entity_type_id' => 4, 'attribute_set_name' => 'Default_3']
+ ]
+ ],
+ 2
+ ], [
+ [
+ 'eav_attribute_group' => [
+ 2 => ['attribute_set_id' => 2, 'attribute_group_name' => 'General'],
+ 7 => ['attribute_set_id' => 3, 'attribute_group_name' => 'General'],
+ 8 => ['attribute_set_id' => 3, 'attribute_group_name' => 'Prices'],
+ 11 => ['attribute_set_id' => 3, 'attribute_group_name' => 'Design'],
+ 12 => ['attribute_set_id' => 4, 'attribute_group_name' => 'General']
+ ],
+ 'eav_entity_type' => [
+ 'customer' => ['entity_type_id' => 1],
+ 'catalog_product' => ['entity_type_id' => 4],
+ 'order' => ['entity_type_id' => 5]
+ ],
+ 'eav_attribute_set' => [
+ 1 => ['attribute_set_id' => 1, 'entity_type_id' => 2, 'attribute_set_name' => 'Custom'],
+ 2 => ['attribute_set_id' => 2, 'entity_type_id' => 3, 'attribute_set_name' => 'Default'],
+ 3 => ['attribute_set_id' => 3, 'entity_type_id' => 4, 'attribute_set_name' => 'Default_2'],
+ 4 => ['attribute_set_id' => 4, 'entity_type_id' => 4, 'attribute_set_name' => 'Default_3']
+ ]
+ ],
+ 1
+ ],
+ ];
+ }
+}
diff --git a/tests/unit/testsuite/Migration/Step/Eav/IntegrityTest.php b/tests/unit/testsuite/Migration/Step/Eav/IntegrityTest.php
index 1a1020c5d..1417c0db5 100644
--- a/tests/unit/testsuite/Migration/Step/Eav/IntegrityTest.php
+++ b/tests/unit/testsuite/Migration/Step/Eav/IntegrityTest.php
@@ -47,6 +47,11 @@ class IntegrityTest extends \PHPUnit_Framework_TestCase
*/
protected $map;
+ /**
+ * @var \Migration\Model\Eav\AttributeGroupNameToCodeMap|\PHPUnit_Framework_MockObject_MockObject
+ */
+ protected $attributeGroupNameToCodeMap;
+
/**
* @return void
*/
@@ -68,6 +73,10 @@ public function setUp()
$this->map = $this->getMockBuilder('\Migration\Reader\Map')->disableOriginalConstructor()
->setMethods(['getDocumentMap', 'getDocumentList', 'getFieldMap', 'isDocumentIgnored'])
->getMock();
+ $this->attributeGroupNameToCodeMap = $this->getMockBuilder('Migration\Step\Eav\Integrity\AttributeGroupNames')
+ ->setMethods(['checkAttributeGroupNames'])
+ ->disableOriginalConstructor()
+ ->getMock();
/** @var \Migration\Reader\MapFactory|\PHPUnit_Framework_MockObject_MockObject $mapFactory */
$mapFactory = $this->getMock('\Migration\Reader\MapFactory', [], [], '', false);
@@ -92,7 +101,8 @@ public function setUp()
$this->source,
$this->destination,
$mapFactory,
- $groupsFactory
+ $groupsFactory,
+ $this->attributeGroupNameToCodeMap
);
}
diff --git a/tests/unit/testsuite/Migration/Step/Eav/VolumeTest.php b/tests/unit/testsuite/Migration/Step/Eav/VolumeTest.php
index 1abe64ea4..17550c95b 100644
--- a/tests/unit/testsuite/Migration/Step/Eav/VolumeTest.php
+++ b/tests/unit/testsuite/Migration/Step/Eav/VolumeTest.php
@@ -59,7 +59,8 @@ public function setUp()
'getDestinationRecords',
'getSourceRecordsCount',
'getDestinationRecordsCount',
- 'deleteBackups'
+ 'deleteBackups',
+ 'clearIgnoredAttributes'
]
)->getMock();
$this->logger = $this->getMockBuilder('\Migration\Logger\Logger')->disableOriginalConstructor()
@@ -153,6 +154,8 @@ public function testPerform()
$this->initialData->expects($this->once())->method('getAttributeGroups')->willReturn(1);
$this->helper->expects($this->any())->method('getDestinationRecordsCount')->willReturn(2);
$this->helper->expects($this->once())->method('deleteBackups');
+ $this->helper->expects($this->any())->method('clearIgnoredAttributes')->with($eavAttributes)
+ ->willReturn($eavAttributes);
$this->logger->expects($this->never())->method('addRecord');
$documentsMap = $this->getDocumentsMap();
diff --git a/tests/unit/testsuite/Migration/Step/UrlRewrite/Version191to2000Test.php b/tests/unit/testsuite/Migration/Step/UrlRewrite/Version191to2000Test.php
index ca192961e..70fd39c68 100644
--- a/tests/unit/testsuite/Migration/Step/UrlRewrite/Version191to2000Test.php
+++ b/tests/unit/testsuite/Migration/Step/UrlRewrite/Version191to2000Test.php
@@ -47,6 +47,16 @@ class Version191to2000Test extends \PHPUnit_Framework_TestCase
*/
protected $recordFactory;
+ /**
+ * @var int
+ */
+ private $recordsAmount = 123;
+
+ /**
+ * @var int
+ */
+ private $pageSize = 20;
+
/**
* @return void
*/
@@ -190,13 +200,13 @@ public function testIntegrity()
*/
public function testData()
{
- $countCmsPageRewrites = 1;
- $recordsAmount = 123;
- $progressRecordsAmount = $recordsAmount + $countCmsPageRewrites;
-
+ $progressRecordsAmount = ceil($this->recordsAmount / $this->pageSize);
$this->source->expects($this->once())
->method('getRecordsCount')
- ->willReturn($recordsAmount);
+ ->willReturn($this->recordsAmount);
+ $this->source->expects($this->once())
+ ->method('getPageSize')
+ ->willReturn($this->pageSize);
$this->progress->expects($this->at(0))
->method('start')
->with($this->equalTo($progressRecordsAmount));
@@ -231,7 +241,7 @@ public function testData()
[\Migration\Step\UrlRewrite\Version191to2000::DESTINATION_PRODUCT_CATEGORY]
);
- $this->source->expects($this->at(2))
+ $this->source->expects($this->at(3))
->method('getRecords')
->with($this->equalTo(\Migration\Step\UrlRewrite\Version191to2000::SOURCE), $this->equalTo(0))
->willReturn(['RecordData1']);