I want to update all product price by specific percentage from current price.I got the following line of code update price by percentage wise
$products = Mage::getModel('catalog/product')->getCollection()
->addAttributeToSelect('price');
foreach ($products as $product) {
$product->setPrice($product->getPrice() * 1.03);
$product->save();
echo $product->getId()."updated Sucess";
}
Its working well. But it will take so much time to complete the above process because we have a lot of products in our store. Some times it will return time out error too. So i want to perform this above operation by split those product collections like if we have 1000 products, do this operation by like below
Collect 1st 100 products from product collections
Update price of those products
Then collect next 100 products
Update price of those products
Anybody have an idea to get product collections by some range of ids?
$_productCOllection = Mage::getModel('catalog/product')->getCollection()
->addAttributeToSelect('*')
->addAttributeToFilter('entity_id', array(
'from' => $startPrOID,
'to' => $EndPrOID
))
->load();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With