Demac Media Demac Media Brand Demac Media Brand



Mini Tutorial: The Fix for an Unintended Price Change when Updating a Product

Timer Icon 1 Min

Magento Commerce, Magento Tutorials

I was trying to manipulate the price of a store when a back-end controller, when something weird happened.  The default price got modified too when the product saves!

The code was very straight forward.  It was something like this…

$product = Mage::getModel(‘catalog/product’)->setStore(3)->load(12);


It ended up changing default value.  I had no idea what the heck was happening.  I tried to debug it, but there wasn’t much progress on that.  Due to a time constraint,  I ended up finding an alternative solution,  using the product mass update function:

Mage::getSingleton(‘catalog/product_action’)->updateAttributes(array(20),array(‘price’=>5.00), 3);

Hurray!… It changed the value without messing up the default one.  The performance also increased by using this function.  I didn’t have a proper test, but the load time after  clicking the save button, to save 300 product price changes was shorten by at least 1/5.  I think saving an attribute is less resource intensive than saving whole product.  That was an interesting discovery!

Subscribe to the Blog

Stay updated with 20,000+ eCommerce leaders in our community

Sign Up

Let’s talk about your 10X return

Icon/Social/Phone Contact us for pricing information