data-migration-tool icon indicating copy to clipboard operation
data-migration-tool copied to clipboard

Data Migration: Default attributes missing in attribute aets if it is not in default Magento 2 attribute set

Open Darkwolf81 opened this issue 4 years ago • 10 comments

Preconditions

  1. Magento 1.9.4.4, PHP 7.2
  2. Magento 2.3.5, PHP 7.2
  3. Data Migration Tool 2.3.5

Steps to reproduce

  1. Source store has attribute sets with manufacturer attribute
  2. Magento 2 default attribute set has not the manufacturer attribute in it
  3. After migration, all migrated attribute sets are missing the manufacturer attribute

Expected result

Attribute Sets have the same attributes as the source store

Actual result

So far i understand following happens: The Migration Tool copies the default attribute set of Magento 2 and inserts the new attributes from the old store. So the new Attribute Sets have no assigned manufacturer attribute. It does not reassign the manufacturer attribute to the new / default attribute sets, if the source store attribute sets had this attribute. Additional, the attribute values of all products are there till the PostProcessing. The PostProcessing Cleanup deletes the manufacturer values from every product, because the attribute is in no attribute set.

Additional notes

When i add manufacturer to the default attribute set in Magento 2 before data migration, everything works.

Darkwolf81 avatar May 26 '20 16:05 Darkwolf81

Hi @Darkwolf81. Thank you for your report. To help us process this issue please make sure that you provided sufficient information.

Please, add a comment to assign the issue: @magento I am working on this


m2-assistant[bot] avatar May 26 '20 16:05 m2-assistant[bot]

What is the attribute called inside Magento 1?

I just checked and I do not have attribute manufacturer in Magento 1, but I do notice there is an attribute manufacturer in Magento 2 - but it is empty (obviously because my Magento 1 instance does not have that attribute.

ChameleonDevil avatar May 27 '20 14:05 ChameleonDevil

Hello, the attribute in magento 1 is manufacturer. I just tried to install a fresh Magento 1.9.4.4 (without sample data or something), screen attached. There is a manufacturer attribute.

Unbenannt

Regards, Andreas

Darkwolf81 avatar May 27 '20 15:05 Darkwolf81

I just checked again - my Magento 1.7.0.2 installation do not have manufacturer field.

You are correct though : There is definitely an attribute in Magento 2 - Search Results, however this migration tool does not seem to specifically target this attribute on import.

Unfortunately since Magento 1.7.0.2 does not have this attribute I cannot really advise anything.

Do you get any results in either of your databases (M1/M2):

SELECT * FROM catalog_product_entity cpe INNER JOIN catalog_product_entity_int cint ON cpe.entity_id = cint.entity_id WHERE cint.attribute_id IN (SELECT attribute_id FROM eav_attribute ea WHERE attribute_code = 'manufacturer');

EDIT: Just read your comment again :

"When i add manufacturer to the default attribute set in Magento 2 before data migration, everything works."

ChameleonDevil avatar May 28 '20 10:05 ChameleonDevil

The Shop i support started from 1.6 or 1.7. Manufacturer was part of the base installation. Attribute ID is 70, Image is 74. So the attribute was part of the base installation. The migration is working, the manufacturer data is completely migrated. Just the attribute is not correctly added to the attribute sets.

Darkwolf81 avatar May 28 '20 10:05 Darkwolf81

Have similar issue, but also lost all manufacturer attribute values, except where its set to NULL. image After investigation I found that at PostProcessing Step class Migration\Step\PostProcessing\Data\AttributeSetLeftoverDataCleaner do the cleaning process: "Records which are still in product entity tables but product attribute no longer exist in attribute set". As a case - you can delete <document>catalog_product_entity_int</document> from <group name="documents_attribute_set_leftover_values"> at yours eav-document-groups.xml file. But maybe is the better way, than this or manually adding attribute to some attribute set before migration.

Preconditions:

  1. Magento Open Source 1.9.4.5
  2. Magento Open Source 2.3.5
  3. Migration Tool 2.3.5

zenfork avatar Jul 23 '20 15:07 zenfork

As a quick fix I created SQL-query that adds existed manufacture attribute to Product details attribute set. Run before launching data migration:

INSERT INTO eav_entity_attribute (entity_attribute_id, entity_type_id, attribute_set_id, attribute_group_id, attribute_id, sort_order)
SELECT NULL, ea.entity_type_id, eas.attribute_set_id, agi.attribute_group_id, ea.attribute_id, '110' FROM eav_attribute AS ea 
	LEFT JOIN eav_attribute_set AS eas ON ea.entity_type_id = eas.entity_type_id
	LEFT JOIN eav_attribute_group AS agi ON ea.entity_type_id = agi.attribute_set_id
	WHERE ea.attribute_code = 'manufacturer' AND eas.attribute_set_name = 'Default' AND agi.attribute_group_code = 'product-details';

zenfork avatar Jul 24 '20 13:07 zenfork

You may should take a look at these changes: https://github.com/magento/data-migration-tool/blob/2.3/src/Migration/Step/Eav/Data.php#L127 https://github.com/magento/data-migration-tool/blob/2.3/src/Migration/Step/Eav/Model/Data.php#L46

mklooss avatar Aug 11 '20 11:08 mklooss

Currently fixed the issues with this SQL in the new Magento 2.3.5-p2 Setup:

You have to run this before you import the "data":

update eav_attribute_group set attribute_group_name = 'Product Details' where attribute_set_id IN(select attribute_set_id from eav_attribute_set AS eas JOIN eav_entity_type AS eet ON (eet.entity_type_id = eas.entity_type_id) where eet.entity_type_code='catalog_product') AND attribute_group_name = 'General';

this code will add manufacturer to the default attribute set

INSERT INTO eav_entity_attribute (entity_attribute_id, entity_type_id, attribute_set_id, attribute_group_id, attribute_id, sort_order)
SELECT
    NULL as entity_attribute_id,
    eet.entity_type_id as entity_type_id,
    eag.attribute_set_id as attribute_set_id,
    eag.attribute_group_id as attribute_group_id,
    ea.attribute_id AS attribute_id,
    999 AS sort_order
FROM eav_attribute AS ea
JOIN eav_attribute_group AS eag ON eag.attribute_group_name = 'Product Details'
JOIN eav_entity_type AS eet ON eet.entity_type_code='catalog_product'
WHERE attribute_code = 'manufacturer'
LIMIT 1;

so i don't have to enter the backend before i am re-running the data migration

Looks like Magento changed Naming of the first "Product Attribute Set Group"

mklooss avatar Aug 12 '20 11:08 mklooss

@mklooss , thanks a lot for your finding. That actually helped me to solve my issue. But it's not Magento who change the naming. In a clean M2 instance, the group is correctly called 'Product Details'. In my case I found the following reason for this issue:

If a third party module adds a product attribute to the well known group 'General' from Magento 1 (or any other random name), the group Product Details is renamed and so can not be found any more. Like you said, to fix that, either rename the attribute group with the attribute_group_code = product-details back to Product Details before starting the migration or find the extension which causes the issue. For that set a breakpoint at \Magento\Eav\Setup\EavSetup::updateAttributeGroup with a filter for the correct id and check where the wrong setting comes from. It happens as soon as this extension sets the group for the attribute in a wrong way. Hope, that helps someone.

norgeindian avatar Nov 03 '20 13:11 norgeindian