Skip to content

Commit 6c73483

Browse files
committed
magento#888 update custom product attribute groups sort order
1 parent b53f0aa commit 6c73483

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Diff for: src/Migration/Step/Eav/Data.php

+7-1
Original file line numberDiff line numberDiff line change
@@ -392,15 +392,18 @@ private function migrateAttributeGroups($attributeGroupIds)
392392
$sourceRecord = $this->factory->create(['document' => $sourceDocument, 'data' => $recordData]);
393393
$destinationRecord = $this->factory->create(['document' => $destinationDocument]);
394394
$recordTransformer->transform($sourceRecord, $destinationRecord);
395-
$recordsToSave->addRecord($destinationRecord);
395+
396396

397397
$sourceAttributeGroupName = $recordData['attribute_group_name'];
398398
$destAttributeGroupName = $destinationRecord->getValue('attribute_group_name');
399399
if (in_array($recordData['attribute_set_id'], $productAttributeSetIds)
400400
&& !in_array($sourceAttributeGroupName, $attributeNameMapping)
401401
&& $sourceAttributeGroupName != $destAttributeGroupName ) {
402402
$attributeNameMapping[$sourceAttributeGroupName] = $destAttributeGroupName;
403+
$sortOrder = $destinationRecord->getValue('sort_order') + 200;
404+
$destinationRecord->setValue('sort_order', $sortOrder);
403405
}
406+
$recordsToSave->addRecord($destinationRecord);
404407
}
405408
$this->saveRecords($destinationDocument, $recordsToSave);
406409
$this->mapProductAttributeGroupNamesSourceDest = $attributeNameMapping;
@@ -645,6 +648,9 @@ private function createMapAttributeSetIds()
645648
);
646649
foreach ($this->initialData->getAttributeSets(ModelData::TYPE_DEST) as $attributeSetId => $record) {
647650
$entityTypeId = $this->mapEntityTypeIdsDestOldNew[$record['entity_type_id']];
651+
if (!isset($this->newAttributeSets[$entityTypeId . '-' . $record['attribute_set_name']])) {
652+
continue;
653+
}
648654
$newAttributeSet = $this->newAttributeSets[$entityTypeId . '-' . $record['attribute_set_name']];
649655
$this->mapAttributeSetIdsDestOldNew[$attributeSetId] = $newAttributeSet['attribute_set_id'];
650656
$this->defaultAttributeSetIds[$newAttributeSet['entity_type_id']] = $newAttributeSet['attribute_set_id'];

0 commit comments

Comments
 (0)