[Magento 2] Update product attribute programmatically

It’s pretty easy when you have the eavSetup in your setup module. It’s only necessary to execute:

$eavSetup->updateAttribute(Product::ENTITY, $attributeCode, $attributeField, $value);

For example, if I want to change the ‘position’ field value of the ‘price’ product attribute:

$eavSetup->updateAttribute('catalog_product', 'price', 'position', 100);

Leave a Reply

Your email address will not be published.