0

I have a schema with multiple websites, one store for each website, and multiple storeviews for each store / website.

I want to update a price in the Default Values with the following code:

$product = Mage::getModel('catalog/product')->load($productId);
$product->setPrice($price)->save();

The price is updated, but the model API overrides every single property of the product for the default store view of the store of the default website (with overrides I mean that the Use Default Value tick box is untoggled after the update).

How can I avoid this?

3

Try it like this.

Mage::getSingleton('catalog/product_action')
    ->updateAttributes(array($productId), array('price'=>$price), 0);
0

The solution is to load the product from the Default Store View:

$product = Mage::getModel('catalog/product')->setStoreId(0)->load($productId);
$product->setPrice($price)->save();

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.