There are many ways to bulk update product attributes in Magento, each well suited to a different purpose. Magento’s built-in mass product attribute updater is great if you want to modify a selection of products or the new attribute value is the same for all products you want to edit. However, if you wish to alter the attributes in more dynamic ways, updating them programmatically via PHP custom file is probably a better way.
You can create a new file in the root directory of Magento say “price_updater.php” and write the below code in that. Once done upload the new “price_updater.php” file on your server root directory of Magento. After successful upload run the script using browser window.
Please note you need to change the value of 1.02 at “($_product->getPrice () * 1.02)” as per your requirement. 1.02 will increase the price by 2% on each product.
<?php require ‘app/Mage.php’; Mage::app();
$products = Mage::getModel(‘catalog/product’)->getCollection() ->addAttributeToSelect(‘price’) ;
foreach ($products as $product) {
$product->setPrice($product->getPrice() * 1.03);
$product->save();
}
?>
Leave a Reply