I want to reset 1 multiselect attribute for all products.

So remove any value (set to null) for all products and save

Ideally targetting the products that have a value set ... it makes no sense to unset data that is not set

So the logic would be - find all products with at least some data set for 1 multiselect attribute - unset the data - save

question: how can this be done?



The simplest way is to delete the data from the database. With that approach you don't need to find products, load and save them.

Multiselect attributes usually have the backend_type = varchar. You can check that for your attribute by running the SQL statement:

select * from eav_attribute where attribute_code = '[YOUR_ATTRIBUTE_CODE]';

If it is a varchar attribute you can delete all values of this attribute for all products by running the following statement:

delete v from catalog_product_entity_varchar v
join  catalog_product_entity p 
  on p.entity_id = v.entity_id
join eav_attribute a 
     on v.attribute_id = a.attribute_id and a.attribute_code = '[YOUR_ATTRIBUTE_CODE]';

If you want to test the statement for a single product first you can simply add where p.sku = '[YOUR SKU] to the statement and it will delete only the values for that product.

I hope that helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.