Aug 15, 2017

Magento 2 - Best way to mass update attribute value of a product.

Here my code.
$productIds = [1,2,34]; // List of product Ids
$productAttribute = \Magento\Framework\App\ObjectManager::getInstance()
            ->create('Magento\Catalog\Model\ResourceModel\Product\Action');
$productAttribute->updateAttributes($productIds, 
['name' => 'New Name for all product'], // List of attribute you want to update NVP
$storeId
);

Idea gets from best-way-to-update-products-attribute-value

No comments: