Skip to content

Commit

Permalink
magento#888 update custom product attribute group mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
schnere committed Feb 13, 2022
1 parent be552e7 commit b53f0aa
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Migration/Step/Eav/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down

0 comments on commit b53f0aa

Please sign in to comment.