{"id":110747,"date":"2018-02-02T12:44:20","date_gmt":"2018-02-02T12:44:20","guid":{"rendered":"https:\/\/webkul.com\/blog\/?p=110747"},"modified":"2025-12-17T13:40:33","modified_gmt":"2025-12-17T13:40:33","slug":"mass-update-products-attribute-magento-2","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/mass-update-products-attribute-magento-2\/","title":{"rendered":"Mass Update Products attribute in Magento 2"},"content":{"rendered":"\n<p>We\u2019ll explore effective ways to mass update <a href=\"https:\/\/webkul.com\/blog\/add-custom-product-attributes-in-magento-2\/\">product attributes in Magento 2<\/a> to streamline catalog management and improve overall store efficiency.<\/p>\n\n\n\n<p>For instance, if you&#8217;ve added a new attribute with the attribute code &#8216;wk_shipping&#8217; and need to assign 50 units to it across multiple products.<\/p>\n\n\n\n<p>Use the following code to save attribute value for products:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">$objectManager = \\Magento\\Framework\\App\\ObjectManager::getInstance();\n$array_product = &#091;1,2,3,4,5]; \/\/product Ids\n$value = 50; \/\/amount\n$productActionObject = $objectManager-&gt;create(&#039;Magento\\Catalog\\Model\\Product\\Action&#039;);\n$productActionObject-&gt;updateAttributes($array_product, array(&#039;wk_shipping&#039; =&gt; $value), 0);<\/pre>\n\n\n\n<p>The function updateAttributes prototype is as such:<br><em>\/**<br>* Update attribute values for entity list per store<br>*<br>* @param array $productIds<br>* @param array $attrData<br>* @param int $storeId<br>* @return $this<br>*\/<\/em><br><em>public function updateAttributes($productIds, $attrData, $storeId);<\/em><\/p>\n\n\n\n<p>Please check the below images for reference. The value for the product attribute &#8220;wk_shipping&#8221; was initially set to $99. After running the above code, the value for the same attribute is updated to the given value, that is, $50 in our case.<\/p>\n\n\n\n<p>Before:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" width=\"1285\" height=\"720\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/02\/image-10.png\" alt=\"image-10\" class=\"wp-image-364245\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/02\/image-10.png 1285w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/02\/image-10-300x168.png 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/02\/image-10-1200x672.png 1200w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/02\/image-10-250x140.png 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/02\/image-10-768x430.png 768w\" sizes=\"(max-width: 1285px) 100vw, 1285px\" loading=\"lazy\" \/><\/figure>\n\n\n\n<p>After:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" width=\"1274\" height=\"713\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/02\/image-11-1.png\" alt=\"image-11-1\" class=\"wp-image-364246\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/02\/image-11-1.png 1274w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/02\/image-11-1-300x168.png 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/02\/image-11-1-1200x672.png 1200w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/02\/image-11-1-250x140.png 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/02\/image-11-1-768x430.png 768w\" sizes=\"(max-width: 1274px) 100vw, 1274px\" loading=\"lazy\" \/><\/figure>\n\n\n\n<p>I have tried to make a standalone script that is ready to use. You can improve the 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. <\/p>\n\n\n\n<p>For any query, do let me know in the comment below. Thanks \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We\u2019ll explore effective ways to mass update product attributes in Magento 2 to streamline catalog management and improve overall store efficiency. For instance, if you&#8217;ve added a new attribute with the attribute code &#8216;wk_shipping&#8217; and need to assign 50 units to it across multiple products. Use the following code to save attribute value for products: <a href=\"https:\/\/webkul.com\/blog\/mass-update-products-attribute-magento-2\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":116,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[302],"tags":[],"class_list":["post-110747","post","type-post","status-publish","format-standard","hentry","category-magento2"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Mass Update Products attribute in Magento 2 - Webkul Blog<\/title>\n<meta name=\"description\" content=\"How to mass update product attributes in Magento 2, saving time, reducing manual effort, and ensuring consistent product data across your store.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/webkul.com\/blog\/mass-update-products-attribute-magento-2\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Mass Update Products attribute in Magento 2 - Webkul Blog\" \/>\n<meta property=\"og:description\" content=\"How to mass update product attributes in Magento 2, saving time, reducing manual effort, and ensuring consistent product data across your store.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/mass-update-products-attribute-magento-2\/\" \/>\n<meta property=\"og:site_name\" content=\"Webkul Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webkul\/\" \/>\n<meta property=\"article:published_time\" content=\"2018-02-02T12:44:20+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-12-17T13:40:33+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2018\/02\/image-10.png\" \/>\n<meta name=\"author\" content=\"Ayaz Mittaqi\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webkul\" \/>\n<meta name=\"twitter:site\" content=\"@webkul\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ayaz Mittaqi\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/webkul.com\/blog\/mass-update-products-attribute-magento-2\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/mass-update-products-attribute-magento-2\/\"},\"author\":{\"name\":\"Ayaz Mittaqi\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/3a9d84d349b963ed99f7aead9372dd6d\"},\"headline\":\"Mass Update Products attribute in Magento 2\",\"datePublished\":\"2018-02-02T12:44:20+00:00\",\"dateModified\":\"2025-12-17T13:40:33+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/mass-update-products-attribute-magento-2\/\"},\"wordCount\":191,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/mass-update-products-attribute-magento-2\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2018\/02\/image-10.png\",\"articleSection\":[\"Magento2\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/mass-update-products-attribute-magento-2\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/mass-update-products-attribute-magento-2\/\",\"url\":\"https:\/\/webkul.com\/blog\/mass-update-products-attribute-magento-2\/\",\"name\":\"Mass Update Products attribute in Magento 2 - Webkul Blog\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/mass-update-products-attribute-magento-2\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/mass-update-products-attribute-magento-2\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2018\/02\/image-10.png\",\"datePublished\":\"2018-02-02T12:44:20+00:00\",\"dateModified\":\"2025-12-17T13:40:33+00:00\",\"description\":\"How to mass update product attributes in Magento 2, saving time, reducing manual effort, and ensuring consistent product data across your store.\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/mass-update-products-attribute-magento-2\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/mass-update-products-attribute-magento-2\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/mass-update-products-attribute-magento-2\/#primaryimage\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/02\/image-10.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/02\/image-10.png\",\"width\":1285,\"height\":720,\"caption\":\"image-10\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/mass-update-products-attribute-magento-2\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Mass Update Products attribute in Magento 2\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/webkul.com\/blog\/#website\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"name\":\"Webkul Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/webkul.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/webkul.com\/blog\/#organization\",\"name\":\"WebKul Software Private Limited\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"width\":380,\"height\":380,\"caption\":\"WebKul Software Private Limited\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webkul\/\",\"https:\/\/x.com\/webkul\",\"https:\/\/www.instagram.com\/webkul\/\",\"https:\/\/www.linkedin.com\/company\/webkul\",\"https:\/\/www.youtube.com\/user\/webkul\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/3a9d84d349b963ed99f7aead9372dd6d\",\"name\":\"Ayaz Mittaqi\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/9a683a7c995567db93858f0305606f73f9075f82330789701e3ed345f6f830aa?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/9a683a7c995567db93858f0305606f73f9075f82330789701e3ed345f6f830aa?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"caption\":\"Ayaz Mittaqi\"},\"url\":\"https:\/\/webkul.com\/blog\/author\/ayaz-mittaqi024\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Mass Update Products attribute in Magento 2 - Webkul Blog","description":"How to mass update product attributes in Magento 2, saving time, reducing manual effort, and ensuring consistent product data across your store.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/webkul.com\/blog\/mass-update-products-attribute-magento-2\/","og_locale":"en_US","og_type":"article","og_title":"Mass Update Products attribute in Magento 2 - Webkul Blog","og_description":"How to mass update product attributes in Magento 2, saving time, reducing manual effort, and ensuring consistent product data across your store.","og_url":"https:\/\/webkul.com\/blog\/mass-update-products-attribute-magento-2\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2018-02-02T12:44:20+00:00","article_modified_time":"2025-12-17T13:40:33+00:00","og_image":[{"url":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2018\/02\/image-10.png","type":"","width":"","height":""}],"author":"Ayaz Mittaqi","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Ayaz Mittaqi","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/mass-update-products-attribute-magento-2\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/mass-update-products-attribute-magento-2\/"},"author":{"name":"Ayaz Mittaqi","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/3a9d84d349b963ed99f7aead9372dd6d"},"headline":"Mass Update Products attribute in Magento 2","datePublished":"2018-02-02T12:44:20+00:00","dateModified":"2025-12-17T13:40:33+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/mass-update-products-attribute-magento-2\/"},"wordCount":191,"commentCount":0,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"image":{"@id":"https:\/\/webkul.com\/blog\/mass-update-products-attribute-magento-2\/#primaryimage"},"thumbnailUrl":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2018\/02\/image-10.png","articleSection":["Magento2"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/mass-update-products-attribute-magento-2\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/mass-update-products-attribute-magento-2\/","url":"https:\/\/webkul.com\/blog\/mass-update-products-attribute-magento-2\/","name":"Mass Update Products attribute in Magento 2 - Webkul Blog","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/webkul.com\/blog\/mass-update-products-attribute-magento-2\/#primaryimage"},"image":{"@id":"https:\/\/webkul.com\/blog\/mass-update-products-attribute-magento-2\/#primaryimage"},"thumbnailUrl":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2018\/02\/image-10.png","datePublished":"2018-02-02T12:44:20+00:00","dateModified":"2025-12-17T13:40:33+00:00","description":"How to mass update product attributes in Magento 2, saving time, reducing manual effort, and ensuring consistent product data across your store.","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/mass-update-products-attribute-magento-2\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/mass-update-products-attribute-magento-2\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/mass-update-products-attribute-magento-2\/#primaryimage","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/02\/image-10.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/02\/image-10.png","width":1285,"height":720,"caption":"image-10"},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/mass-update-products-attribute-magento-2\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Mass Update Products attribute in Magento 2"}]},{"@type":"WebSite","@id":"https:\/\/webkul.com\/blog\/#website","url":"https:\/\/webkul.com\/blog\/","name":"Webkul Blog","description":"","publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/webkul.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/webkul.com\/blog\/#organization","name":"WebKul Software Private Limited","url":"https:\/\/webkul.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","width":380,"height":380,"caption":"WebKul Software Private Limited"},"image":{"@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webkul\/","https:\/\/x.com\/webkul","https:\/\/www.instagram.com\/webkul\/","https:\/\/www.linkedin.com\/company\/webkul","https:\/\/www.youtube.com\/user\/webkul\/"]},{"@type":"Person","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/3a9d84d349b963ed99f7aead9372dd6d","name":"Ayaz Mittaqi","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/9a683a7c995567db93858f0305606f73f9075f82330789701e3ed345f6f830aa?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/9a683a7c995567db93858f0305606f73f9075f82330789701e3ed345f6f830aa?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","caption":"Ayaz Mittaqi"},"url":"https:\/\/webkul.com\/blog\/author\/ayaz-mittaqi024\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/110747","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/users\/116"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=110747"}],"version-history":[{"count":6,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/110747\/revisions"}],"predecessor-version":[{"id":517834,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/110747\/revisions\/517834"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=110747"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=110747"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=110747"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}