I have different stores of different products. I want to change all products prices of particular store. I have a code of it. But it takes so much time on save function because i have so many products.

$product = Mage::getModel('catalog/product')

Is there any better way?


You can quick update attribute using ->getResource()->saveAttribute('yourattriibutecode');

$product = Mage::getModel('catalog/product')

$product->setPrice($price)->getResource()->saveAttribute($product, 'price');

Here you did not need save() which take lot of time;

See at :

Fastest way to update an attribute in all products



$product->getResource()->saveAttribute($product, 'special_price');
$product->getResource()->saveAttribute($product, 'special_from_date');
$product->getResource()->saveAttribute($product, 'special_to_date');
  • Thanks Amit, i successfully updated my all products prices through your code but now i have got another problem. Now my all products are showing regular and special prices. i want to set just one price for each product. – umair ayub Nov 14 '14 at 13:25
  • make special price null using my code $product->setSpecialFromDate();$product->setSpecialToDate();$product->setSpecialPrice(''); – Amit Bera Nov 14 '14 at 13:31
  • and use >getResource()->saveAttribute($product, 'attibutecode'); every attribute – Amit Bera Nov 14 '14 at 13:32
  • I am sorry Amit, i am new in Magento. can you please write me a just one fine code as you wrote first. I am confused now. Thank You – umair ayub Nov 14 '14 at 13:40
  • Amit I am getting error.Call to a member function getBackend() on a non-object. – umair ayub Nov 16 '14 at 10:16

The fast solution for updating attributes is this

    array('price' => $price),

But in your case there is a catch. The price attribute scope can be global or website. You shouldn't change the price for a store view.
I'm not sure it even works, and even if it does, you will lose the value the next time you manually save a product because of the price attribute scope.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.