Menu Close
    Start a Project Request quote Reading list Switch to dark mode
    magento-marketplace-mod

    Mass Update Products attribute in Magento 2

    In this post, we will see How we can Update Products attribute for a large number of products in most optimised way possible. Suppose, you have added a product attribute with attribute code ‘wk_shipping’. You want to set 50 unit to this for a large number of products.

    Use the following code to Save attribute value for Products:


    The function updateAttributes prototype is as such:
    /**
    * Update attribute values for entity list per store
    *
    * @param array $productIds
    * @param array $attrData
    * @param int $storeId
    * @return $this
    */
    public function updateAttributes($productIds, $attrData, $storeId);

    I have tried to make a standalone script which is ready to use. You can improve code by directly injecting the dependency of this class Magento\Catalog\Model\Product\Action in constructor. Hope, this may be helpful in your journey with Magento 2. For any query, do let me know in the comment below. Thanks 🙂

    . . .

    Comment

    Add Your Comment

    Be the first to comment.

    Back to Top
    css.php
    Hire Us!
    Brief us about your requirements and we'll get back to you.
    Woo! Hooy!
    We have just recieved your project brief and our expert will contact you shortly.
    Send Again
    Close