From b53f0aad6970be40183df7fcc7b23b3569ab1fb9 Mon Sep 17 00:00:00 2001 From: Reinhard Schneidewind Date: Sun, 13 Feb 2022 12:44:18 +0100 Subject: [PATCH 1/2] #888 update custom product attribute group mapping --- src/Migration/Step/Eav/Data.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Migration/Step/Eav/Data.php b/src/Migration/Step/Eav/Data.php index f925ea94..6c5adac2 100644 --- a/src/Migration/Step/Eav/Data.php +++ b/src/Migration/Step/Eav/Data.php @@ -385,14 +385,25 @@ private function migrateAttributeGroups($attributeGroupIds) ); $recordsToSave = $destinationDocument->getRecords(); $recordTransformer = $this->helper->getRecordTransformer($sourceDocument, $destinationDocument); + $attributeNameMapping = $this->mapProductAttributeGroupNamesSourceDest; + $productAttributeSetIds = array_keys($this->modelData->getProductAttributeSets()); foreach ($sourceRecords as $recordData) { $recordData['attribute_group_id'] = null; $sourceRecord = $this->factory->create(['document' => $sourceDocument, 'data' => $recordData]); $destinationRecord = $this->factory->create(['document' => $destinationDocument]); $recordTransformer->transform($sourceRecord, $destinationRecord); $recordsToSave->addRecord($destinationRecord); + + $sourceAttributeGroupName = $recordData['attribute_group_name']; + $destAttributeGroupName = $destinationRecord->getValue('attribute_group_name'); + if (in_array($recordData['attribute_set_id'], $productAttributeSetIds) + && !in_array($sourceAttributeGroupName, $attributeNameMapping) + && $sourceAttributeGroupName != $destAttributeGroupName ) { + $attributeNameMapping[$sourceAttributeGroupName] = $destAttributeGroupName; + } } $this->saveRecords($destinationDocument, $recordsToSave); + $this->mapProductAttributeGroupNamesSourceDest = $attributeNameMapping; } /** From 6c7348368eb46714002b9529df608465413b4ac7 Mon Sep 17 00:00:00 2001 From: Reinhard Schneidewind Date: Wed, 16 Feb 2022 11:20:06 +0100 Subject: [PATCH 2/2] #888 update custom product attribute groups sort order --- src/Migration/Step/Eav/Data.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Migration/Step/Eav/Data.php b/src/Migration/Step/Eav/Data.php index 6c5adac2..0d66c27a 100644 --- a/src/Migration/Step/Eav/Data.php +++ b/src/Migration/Step/Eav/Data.php @@ -392,7 +392,7 @@ private function migrateAttributeGroups($attributeGroupIds) $sourceRecord = $this->factory->create(['document' => $sourceDocument, 'data' => $recordData]); $destinationRecord = $this->factory->create(['document' => $destinationDocument]); $recordTransformer->transform($sourceRecord, $destinationRecord); - $recordsToSave->addRecord($destinationRecord); + $sourceAttributeGroupName = $recordData['attribute_group_name']; $destAttributeGroupName = $destinationRecord->getValue('attribute_group_name'); @@ -400,7 +400,10 @@ private function migrateAttributeGroups($attributeGroupIds) && !in_array($sourceAttributeGroupName, $attributeNameMapping) && $sourceAttributeGroupName != $destAttributeGroupName ) { $attributeNameMapping[$sourceAttributeGroupName] = $destAttributeGroupName; + $sortOrder = $destinationRecord->getValue('sort_order') + 200; + $destinationRecord->setValue('sort_order', $sortOrder); } + $recordsToSave->addRecord($destinationRecord); } $this->saveRecords($destinationDocument, $recordsToSave); $this->mapProductAttributeGroupNamesSourceDest = $attributeNameMapping; @@ -645,6 +648,9 @@ private function createMapAttributeSetIds() ); foreach ($this->initialData->getAttributeSets(ModelData::TYPE_DEST) as $attributeSetId => $record) { $entityTypeId = $this->mapEntityTypeIdsDestOldNew[$record['entity_type_id']]; + if (!isset($this->newAttributeSets[$entityTypeId . '-' . $record['attribute_set_name']])) { + continue; + } $newAttributeSet = $this->newAttributeSets[$entityTypeId . '-' . $record['attribute_set_name']]; $this->mapAttributeSetIdsDestOldNew[$attributeSetId] = $newAttributeSet['attribute_set_id']; $this->defaultAttributeSetIds[$newAttributeSet['entity_type_id']] = $newAttributeSet['attribute_set_id'];