I have setup my Magento with 2 websites, with ID 1 and 4, and one store for each website.

Default website is 1.

My product has a Default price.

How can I set programmatically a price for website 4 without touching website 1?

See what I have tried so far:

$product = Mage::getModel('catalog/product')->loadByAttribute('sku', $sku);

Unfortunately the code above leaves unchanged the price for website 4, and overrides Default price for website 1 with $newPrice!

3 Answers 3


I had to set the StoreId, not the websiteId. Just needed to choose a store belonging to the desired website:

$product = Mage::getModel('catalog/product') -> loadByAttribute('sku', $sku);
$product->setStoreId(1) -> setPrice($price1) ->save() ;
$product->setStoreId(9) -> setPrice($price9) ->save();

For This you need below code

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

 $product->setPrice('Yor price');
  • hmm I think you did not get the idea so Just prepare answer for you Thanks :)
    – Keyul Shah
    Jan 19, 2014 at 9:54
  • It looks like this solution has changed the Visibility status to all products!!
    – perissf
    Jan 20, 2014 at 12:40
  • not sure for that but if it will change then set them again
    – Keyul Shah
    Jan 20, 2014 at 12:46

I have been doing exactly this on the latest version ( and the only way i could get it working was to set and unset the store id's as below, this was so i could post a different price in store 2 vs all the other stores (10 on this system)

$product = Mage::getModel('catalog/product')->loadByAttribute('sku', $this->p_sku);
if ($product) {
    $product->setData('price', 19.99);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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