diff --git a/src/Migration/Step/Eav/Data.php b/src/Migration/Step/Eav/Data.php index f925ea94..0d66c27a 100644 --- a/src/Migration/Step/Eav/Data.php +++ b/src/Migration/Step/Eav/Data.php @@ -385,14 +385,28 @@ 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); + + + $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; + $sortOrder = $destinationRecord->getValue('sort_order') + 200; + $destinationRecord->setValue('sort_order', $sortOrder); + } $recordsToSave->addRecord($destinationRecord); } $this->saveRecords($destinationDocument, $recordsToSave); + $this->mapProductAttributeGroupNamesSourceDest = $attributeNameMapping; } /** @@ -634,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'];