Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EAV Step migrates ignored attribute references #159

Closed
pascaladriaansen opened this issue Sep 15, 2016 · 4 comments
Closed

EAV Step migrates ignored attribute references #159

pascaladriaansen opened this issue Sep 15, 2016 · 4 comments

Comments

@pascaladriaansen
Copy link

Hi,

When migrating data with a bunch of attributes ignored in the eav-attribute-groups.xml file, it correctly ignores these attributes and does not migrate them... As in: they don't end up in the eav_attribute table. However, all the references to these attributes (like in the catalog_category_entity_int table) are migrated.

For example:
I have an attribute in my source database: m_show_in_layered_navigation. I have added this attribute to my eav-attribute-groups.xml file by adding the following inside of the <group name="ignored"> node:

<attribute>m_show_in_layered_navigation</attribute>

After migration, when I try to open Products > Categories in the admin panel, I get the following exception:

Exception #0 (Exception): Notice: Undefined offset: 404 in /data/web/magento2/vendor/magento/module-eav/Model/ResourceModel/ReadHandler.php on line 166

The attribute with ID 404 in my source database is the m_show_in_layered_navigation attribute. As the error tells us: it does not exist in our destination database. When I use phpMyAdmin to search my destination database for the string "404" in all tables within the column "attribute_id", I get 36 results within the catalog_category_entity_int, catalog_eav_attribute and eav_entity_attribute tables.

I have tried this on both Magento 2.1 and 2.1.1 (with the corresponding data-migration-tool versions), but I get the same result on both versions. I have seen it happen with both category attributes and product attributes.

The expected behaviour for me is that it should completely ignore all attributes and any reference to it whenever it is specified to be ignored in the eav-attribute-groups.xml file.

@victor-v-rad
Copy link
Collaborator

Thank you for reporting this issue.
The similar one is #134 But you added additional info. Internal ticket to fix it MAGETWO-56809

@victor-v-rad
Copy link
Collaborator

The bug was fixed in the recent release. Please try it out. Feel free to reopen the issue if it is still relevant.

@jarhody
Copy link

jarhody commented Oct 25, 2016

Is there a fix if you have already migrated your live site to say 2.0.7 and now when trying to upgrade and this error pops up? Or is there a clear and clean method to clean up the DB?

I have not been able to update to any version beyond 2.0.7 without experiencing this error. Everything works like a fine in 2.0.7 tho.

@pascaladriaansen
Copy link
Author

@jarhody You could use something dirty/hacky like this to clean up all records for any unwanted attributes that cause the error:

<?php
use Magento\Framework\App\Bootstrap;
require __DIR__ . '/../../app/bootstrap.php';

$bootstrap = Bootstrap::create(BP, $_SERVER);

$obj = $bootstrap->getObjectManager();

$state = $obj->get('Magento\Framework\App\State');
$state->setAreaCode('frontend');

$eav_attribute = array(
  array('entity_type_id' => '1','attribute_code' => 'your_attribute_code_here'),
  array('entity_type_id' => '1','attribute_code' => 'your_attribute_code_here'),
);

$setup = $obj->get('Magento\Eav\Setup\EavSetupFactory');
$eavSetup = $setup->create();

foreach($eav_attribute as $attribute){
    $eavSetup->removeAttribute($attribute['entity_type_id'], $attribute['attribute_code']);
    echo "Removed ".$attribute['attribute_code']." (".$attribute['entity_type_id'].")<br/>";
}

You'll need to supply an array of attribute codes with their entity type id. Be careful with it though - you don't want to remove anything that shouldn't be removed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants