Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
2.4.9
=============
* Added support for versions:

* Magento Open Source: 2.4.9
* Adobe Commerce: 2.4.9

2.4.8
=============
* Added support for versions:
Expand Down
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
{
"name": "magento/data-migration-tool",
"description": "Migration Tool",
"version": "2.4.8.1",
"version": "2.4.9",
"require": {
"symfony/console": "^6.4",
"php": "~8.3.0||~8.4.0||~8.5.0",
"symfony/console": "^7.4",
"magento/framework": "*",
"monolog/monolog": "^3.6"
},
"require-dev": {
"phpunit/phpunit": "~9.5.0"
"phpunit/phpunit": "^12.0"
},
"autoload": {
"psr-4": {"Migration\\": "src/Migration"},
Expand Down
2 changes: 1 addition & 1 deletion src/Migration/App/ConsoleOutputFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class ConsoleOutputFactory
public function create(
$verbosity = ConsoleOutput::VERBOSITY_NORMAL,
$decorated = null,
OutputFormatterInterface $formatter = null
?OutputFormatterInterface $formatter = null
) {
return new ConsoleOutput($verbosity, $decorated, $formatter);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Migration/Console/AbstractMigrateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function __construct(
*
* @return void
*/
protected function configure()
protected function configure(): void
{
$this->setDefinition([
new InputArgument(
Expand Down Expand Up @@ -110,7 +110,7 @@ protected function configure()
* @throws Exception
* @return void
*/
protected function initialize(InputInterface $input, OutputInterface $output)
protected function initialize(InputInterface $input, OutputInterface $output): void
{

$config = $input->getArgument(self::INPUT_KEY_CONFIG);
Expand Down
4 changes: 2 additions & 2 deletions src/Migration/Console/MigrateDataCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function __construct(
*
* @return void
*/
protected function configure()
protected function configure(): void
{
$this->setName($this->name)
->setDescription('Main migration of data');
Expand All @@ -55,7 +55,7 @@ protected function configure()
/**
* @inheritdoc
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$this->dataMode->run();
return Command::SUCCESS;
Expand Down
4 changes: 2 additions & 2 deletions src/Migration/Console/MigrateDeltaCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function __construct(
*
* @return void
*/
protected function configure()
protected function configure(): void
{
$this->setName($this->name)
->setDescription('Migrate the data is added into Magento after the main migration');
Expand All @@ -55,7 +55,7 @@ protected function configure()
/**
* @inheritdoc
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$this->deltaMode->run();
return Command::SUCCESS;
Expand Down
2 changes: 1 addition & 1 deletion src/Migration/Console/MigrateSettingsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function __construct(
*
* @return void
*/
protected function configure()
protected function configure(): void
{
$this->setName($this->name)
->setDescription('Migrate system configuration');
Expand Down
20 changes: 18 additions & 2 deletions src/Migration/Handler/Gallery/InsertValueToEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,24 @@ public function handle(Record $recordToHandle, Record $oppositeRecord)
|| $this->moduleList->has('Magento_CatalogStaging') === false
? $this->entityField
: 'row_id';
$record['value_id'] = $recordToHandle->getValue($this->field);
$record[$entityIdName] = $recordToHandle->getValue($this->entityField);
$valueId = (int)$recordToHandle->getValue($this->field);
$entityId = (int)$recordToHandle->getValue($this->entityField);

$tableName = $this->destination->addDocumentPrefix($this->valueToEntityDocument);
$existing = $this->destination->getAdapter()->loadPage(
$tableName,
0,
1,
null,
null,
new \Zend_Db_Expr(sprintf('`value_id` = %d AND `%s` = %d', $valueId, $entityIdName, $entityId))
);
if (!empty($existing)) {
return;
}

$record['value_id'] = $valueId;
$record[$entityIdName] = $entityId;
$this->destination->saveRecords($this->valueToEntityDocument, [$record]);
}
}
2 changes: 1 addition & 1 deletion src/Migration/ResourceModel/Adapter/Mysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public function loadPage(
$pageSize,
$identityField = null,
$identityId = null,
\Zend_Db_Expr $condition = null
?\Zend_Db_Expr $condition = null
) {
$select = $this->getSelect();
$select->from($documentName, '*');
Expand Down
2 changes: 1 addition & 1 deletion src/Migration/ResourceModel/AdapterInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function loadPage(
$pageSize,
$identityField = null,
$identityId = null,
\Zend_Db_Expr $condition = null
?\Zend_Db_Expr $condition = null
);

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Migration/ResourceModel/Record.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Record
* @param array $data
* @param Document $document
*/
public function __construct(array $data = [], Document $document = null)
public function __construct(array $data = [], ?Document $document = null)
{
$this->data = $data;
if ($document !== null) {
Expand Down
2 changes: 1 addition & 1 deletion src/Migration/ResourceModel/Source.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function loadPage($documentName, $pageNumber)
* @param \Zend_Db_Expr $condition
* @return array
*/
public function getRecords($documentName, $pageNumber, $pageSize = null, \Zend_Db_Expr $condition = null)
public function getRecords($documentName, $pageNumber, $pageSize = null, ?\Zend_Db_Expr $condition = null)
{
$pageSize = $pageSize ?: $this->getPageSize($documentName) ;
$identityField = $this->getIdentityField($documentName);
Expand Down
4 changes: 2 additions & 2 deletions src/Migration/Step/Customer/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public function perform()
*/
private function transformDocumentRecords(
$sourceDocName,
array $attributesToSkip = null
array $attributesToSkip = []
) {
$sourceEntityDocuments = array_keys($this->readerGroups->getGroup('source_entity_documents'));
$sourceDocument = $this->source->getDocument($sourceDocName);
Expand Down Expand Up @@ -244,7 +244,7 @@ private function skipRecordAttribute($recordData, $attributesToSkip)
return false;
};

if ($attributesToSkip !== null
if (!empty($attributesToSkip)
&& isset($recordData['attribute_id'])
&& isset($attributesToSkip[$recordData['attribute_id']])
&& !$passwordHashSha512($recordData, $attributesToSkip)
Expand Down
69 changes: 59 additions & 10 deletions src/Migration/Step/Eav/Model/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,33 @@ public function getProductAttributeSets(
return $attributeSets;
}

/**
* Get list of attribute sets for a given entity type
*
* @param string $mode
* @param string $type
* @param string $entityTypeCode
* @return array
*/
public function getEntityAttributeSets(
$mode = self::ATTRIBUTE_SETS_ALL,
$type = self::TYPE_SOURCE,
$entityTypeCode = self::ENTITY_TYPE_PRODUCT_CODE
) {
$entityTypeId = $this->getEntityTypeIdByCode($entityTypeCode, $type);
$attributeSets = [];
foreach ($this->initialData->getAttributeSets($type) as $attributeSet) {
if ($entityTypeId == $attributeSet['entity_type_id']
&& (($mode == self::ATTRIBUTE_SETS_DEFAULT && $attributeSet['attribute_set_name'] == 'Default')
|| ($mode == self::ATTRIBUTE_SETS_NONE_DEFAULT && $attributeSet['attribute_set_name'] != 'Default')
|| ($mode == self::ATTRIBUTE_SETS_ALL))
) {
$attributeSets[$attributeSet['attribute_set_id']] = $attributeSet;
}
}
return $attributeSets;
}

/**
* Return entity type id by its code
*
Expand Down Expand Up @@ -208,6 +235,36 @@ public function getDefaultProductAttributeGroups()
return $attributeGroups;
}

/**
* Get default attribute groups for any entity type
*
* @param string $entityTypeCode
* @return array
*/
public function getDefaultEntityAttributeGroups($entityTypeCode = self::ENTITY_TYPE_PRODUCT_CODE)
{
$defaultAttributeSet = $this->getEntityAttributeSets(
self::ATTRIBUTE_SETS_DEFAULT,
self::TYPE_DEST,
$entityTypeCode
);

if (!$defaultAttributeSet) {
return [];
}

$defaultAttributeSetId = array_shift($defaultAttributeSet)['attribute_set_id'];
$attributeGroups = [];
foreach ($this->initialData->getAttributeGroups(self::TYPE_DEST) as $attributeGroup) {
if ($attributeGroup['attribute_set_id'] == $defaultAttributeSetId) {
$attributeGroup['attribute_group_id'] = null;
$attributeGroup['attribute_set_id'] = null;
$attributeGroups[] = $attributeGroup;
}
}
return $attributeGroups;
}

/**
* Get default product entity attributes
*
Expand Down Expand Up @@ -298,16 +355,8 @@ public function getCustomAttributeGroups($attributeSetId)
$sourceAttributeGroupNames = [];
$entityTypeCode = $this->getEntityTypeCodeByAttributeSetId($attributeSetId);
$excludedAttributeGroups = $this->excludedAttributeGroups[$entityTypeCode] ?? [];
if ($entityTypeCode == self::ENTITY_TYPE_PRODUCT_CODE) {
foreach ($this->getDefaultProductAttributeGroups() as $attributeGroup) {
$defaultAttributeGroupNames[] = $attributeGroup['attribute_group_name'];
}
} else {
foreach ($this->initialData->getAttributeGroups(self::TYPE_DEST) as $attributeGroup) {
if ($attributeGroup['attribute_set_id'] == $attributeSetId) {
$defaultAttributeGroupNames[] = $attributeGroup['attribute_group_name'];
}
}
foreach ($this->getDefaultEntityAttributeGroups($entityTypeCode) as $attributeGroup) {
$defaultAttributeGroupNames[] = $attributeGroup['attribute_group_name'];
}
foreach ($this->initialData->getAttributeGroups(self::TYPE_SOURCE) as $attributeGroup) {
if ($attributeGroup['attribute_set_id'] == $attributeSetId) {
Expand Down
14 changes: 6 additions & 8 deletions tests/integration/phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@
*/
-->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/6.1/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/12.0/phpunit.xsd"
colors="true"
bootstrap="./framework/bootstrap.php"
>
<testsuite name="Migration tool Integration Tests">
<directory suffix="Test.php">testsuite</directory>
</testsuite>
<!-- Test listeners -->
<listeners>
<listener class="Migration\TestFramework\Listener"/>
</listeners>
<testsuites>
<testsuite name="Migration tool Integration Tests">
<directory suffix="Test.php">testsuite</directory>
</testsuite>
</testsuites>
</phpunit>
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class SetupDeltaLogTest extends \PHPUnit\Framework\TestCase
/**
* @return void
*/
public function setUp()
public function setUp(): void
{
$helper = \Migration\TestFramework\Helper::getInstance();
$this->objectManager = $helper->getObjectManager();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class SourceDestinationTest extends \PHPUnit\Framework\TestCase
/**
* @return void
*/
protected function setUp()
protected function setUp(): void
{
$helper = \Migration\TestFramework\Helper::getInstance();
$objectManager = $helper->getObjectManager();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class DataTest extends \PHPUnit\Framework\TestCase
/**
* @return void
*/
public function setUp()
public function setUp(): void
{
$helper = \Migration\TestFramework\Helper::getInstance();
$objectManager = $helper->getObjectManager();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class IntegrityTest extends \PHPUnit\Framework\TestCase
/**
* @return void
*/
public function setUp()
public function setUp(): void
{
$helper = \Migration\TestFramework\Helper::getInstance();
$objectManager = $helper->getObjectManager();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class DataTest extends \PHPUnit\Framework\TestCase
/**
* @return void
*/
public function setUp()
public function setUp(): void
{
$objectManager = \Migration\TestFramework\Helper::getInstance()->getObjectManager();
$objectManager->get(\Migration\Config::class)->init(dirname(__DIR__) . '/../_files/config.xml');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class IntegrityTest extends \PHPUnit\Framework\TestCase
/**
* @return void
*/
public function setUp()
public function setUp(): void
{
$objectManager = \Migration\TestFramework\Helper::getInstance()->getObjectManager();
$objectManager->get(\Migration\Config::class)->init(dirname(__DIR__) . '/../_files/config.xml');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class VolumeTest extends \PHPUnit\Framework\TestCase
/**
* @return void
*/
public function setUp()
public function setUp(): void
{
$objectManager = \Migration\TestFramework\Helper::getInstance()->getObjectManager();
$objectManager->get(\Migration\Config::class)->init(dirname(__DIR__) . '/../_files/config.xml');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function testPerform()
\Migration\App\Progress::class,
['getProcessedEntities', 'addProcessedEntity']
);
$progress->expects($this->once())->method('getProcessedEntities')->will($this->returnValue([]));
$progress->expects($this->once())->method('getProcessedEntities')->willReturn([]);
$progress->expects($this->any())->method('addProcessedEntity');

$helper = \Migration\TestFramework\Helper::getInstance();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function testPerform()
\Migration\App\Progress::class,
['getProcessedEntities', 'addProcessedEntity']
);
$progress->expects($this->once())->method('getProcessedEntities')->will($this->returnValue([]));
$progress->expects($this->once())->method('getProcessedEntities')->willReturn([]);
$progress->expects($this->any())->method('addProcessedEntity');

$helper = \Migration\TestFramework\Helper::getInstance();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class DataTest extends \PHPUnit\Framework\TestCase
/**
* @return void
*/
public function setUp()
public function setUp(): void
{
$helper = \Migration\TestFramework\Helper::getInstance();
$objectManager = $helper->getObjectManager();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class IntegrityTest extends \PHPUnit\Framework\TestCase
/**
* @return void
*/
public function setUp()
public function setUp(): void
{
$helper = \Migration\TestFramework\Helper::getInstance();
$objectManager = $helper->getObjectManager();
Expand Down
Loading