I created a new customer attribute (Drop Down) and added it to the registration form.

Attribute details found in eav_attribute table:

enter image description here

Everything work as expected, attribute is added to the customer when new account is registered or an existing account was edited and the attribute was added. I can find that in the table customer_entity_int:

enter image description here

Now, I have about 90,000 customers and I need to set a value of this attribute.

How can I update all the customers custom drop down attribute with the above value? Any method would suit me, PHP or SQL.

  • You can use Collection to set attribute value for all customers. – Sourav Nov 27 '18 at 4:11
  • @Sourav thank for tips :) any more advice how to do so? Tutorials or further information? Still struggling... :/ – Greg Nov 27 '18 at 9:10
  • which M2 version you are using ? – Hassan Ali Shahzad Nov 29 '18 at 6:42
  • I am using Magento ver. 2.2.6 – Greg Nov 29 '18 at 16:15

Here is the quick and dirty sql solution:
You need to run this:

INSERT IGNORE INTO customer_entity_int (attribute_id, entity_id, value) 
SELECT 'attribute_id_here' as attribute_id, entity_id, 'default_value' as value from customer_entity;

So let's say you have the attribute id 529 for your new attribute and you want to set the value 1370 for all customers for this attribute, jut run:

INSERT IGNORE INTO customer_entity_int (attribute_id, entity_id, value) 
SELECT 529 as attribute_id, entity_id, 1370 as value from customer_entity;
  • Thanks for reply. I leave the question open for further solutions (if any). – Greg Nov 29 '18 at 16:16
  • If you want a clean versiin you can put this in an upgrade data script – Marius Nov 29 '18 at 17:12

you can create upgrade Data script and set/change following value in your custom attribute array in your module . 'default' => '0',


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.