Magento 2 – Remove All Product Attributes at View Level

magento2product-attributeproducts

I have been working on fixing the product attributes that were imported via CSV files. I noticed that somehow the importers fill in attributes on the store view level, which means the change I made to the All Store Views will not be affecting until I manually go through the Default Store View and set each applicable to fall back to the Default Value.

Is there a way to just remove all of them (via MySQL or code or admin UI)?

Best Answer

the attribute values are kept in the tables catalog_product_entity_* where * can be int, varchar, text, datetime, decimal.
All the default values have the field store_id = 0 and the store view values have store_id the actual store id that is > 0.

So you can delete all the values from these tables where store_id is not 0.

DELETE FROM catalog_product_entity_int WHERE store_id <> 0;
DELETE FROM catalog_product_entity_varchar WHERE store_id <> 0;
DELETE FROM catalog_product_entity_text WHERE store_id <> 0;
DELETE FROM catalog_product_entity_decimal WHERE store_id <> 0;
DELETE FROM catalog_product_entity_datetime WHERE store_id <> 0;

But backup your db just to be safe.

Related Topic