December 14, 2014

Update Multiple Products Atrributes values using UpdateAction Function

Update multiple product id attribute values


To update multiple product attribute values using simple code.
Mage::getSingleton('catalog/product_action')
   ->updateAttributes(
    $productIds, 
    array('[attribute_id]' => [attribute_value])
     );
If you want to update the attribute values for muliple products, then the above code will do the magic for that.

for ex:
Want to update the meta title for multiple products, refer the code below.
/*
$collection refers to the set of product collections
*/
$productIds = $collection->getAllIds();
/*
*print_r($productIds);
*/
Mage::getSingleton('catalog/product_action')
   ->updateAttributes(
    $productIds, 
    array('meta_title' => 'title added')
     );


No comments:

Post a Comment