Question

I have a magento site that was created by the official data migration, but recently I added 2 attributes post migration.

Today I noticed that the "add related/crossell/upsell" grid displays these two attributes. But none of mine. No combination of configuration options changes that.

So I am puzzled as to why, and how.

Alas these new attributes aren't attributes of particular value there but I would love to have other attributes show in these tables it would help a lot.

The same attributes also end up showing by default in the admin product grid for a brand new user, which I am assuming is related.

I could not see anything in the settings and I have been looking around the code :-

app\code\Magento\Catalog\Controller\Adminhtml\Product\CrosssellGrid.php
app\code\Magento\Catalog\Controller\Adminhtml\Product\Crosssell.php
app\code\Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Crosssell.php
app\code\Magento\Catalog\view\adminhtml\layout\catalog_product_crosssellgrid.xml
app\code\Magento\Catalog\view\adminhtml\layout\catalog_product_crosssell.xml

I can't find anything relevant

I am assuming it is another case where Magento Admin has put logic in its admin interface that should be at the code or database defaults level.

Anyone encountered that?

Was it helpful?

Solution

The solution alas in this case is to fix the attributes direct in the database!

In the database table catalog_eav_attribute there is a column is_visible_in_grid

If it is set to 1 the attribute will appear by default in product grids, the main one or the related/upsell/crossell ones

It was set to 1 for user created new attributes and many attributes created by extensions, but it was set to 0 for all migrated attributes.

Setting this to 1 fixed the issue.

NOTE: there is no normal way to set this to 1 in the admin interface as the field is hidden

Why it happens:

First is_visible_in_grid is set to be invisible in the attribute management screens (if it was visible all this would not be a bug)

On creation of an attribute, that invisible field defaults to 1, this is configured in the interface block app\code\Magento\Catalog\Block\Adminhtml\Product\Attribute\Edit\Tab\Advanced.php. All user created attributes are therefore created with is_visible_in_grid ON

On the other hand is_visible_in_grid is set to default to 0 in the database definition. programmatically created attributes need to set it to 1 or else attributes are created with is_visible_in_grid OFF

data migration ignores that attribute, so all user created attributes end up migrated with is_visible_in_grid OFF when it should be ON.

I have filed a bug with the data migration github https://github.com/magento/data-migration-tool/issues/809

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top