2

I am trying to update products prices with in a specific store. But when I do that, it shows me regular and special prices against each product. I want to set just one price against each product by disabling special price. How to do that? Here is my code.

$prod = Mage::getModel('catalog/product')
                    ->setStoreId($storeId)
                    ->load($prodId); 
    $prod->setPrice($newPrice)->getResource()->saveAttribute($prod, 'price');
    $prod->setSpecialPrice('')->getResource()->saveAttribute($prod, 'special_price');
    $prod->setSpecialFromDate('')->getResource()->saveAttribute($prod, 'special_from_date');
    $prod->setSpecialToDate('')->getResource()->saveAttribute($prod, 'special_to_date');
1
  • 1
    is your problem solved
    – Gem
    Jan 4, 2017 at 10:35

2 Answers 2

1

How about this.

$productIds = array($id1 , $id2); // specify your product ids here
$attributes = array( 
                'price' => $newPrice,
                'special_to_date' => '',
                'special_from_date => '',
                'special_price' => null); // attribute codes and values 

$storeId = $someStoreId // change this to your store id

Mage::getSingleton("catalog/product_action')
        ->updateAttributes($productIds , $attributes , $storeId); // update the products
1
  • Hi, I have different prices against each product. So in that scenario your code will work? If yes can you please elaborate your code.Thank You
    – umair ayub
    Nov 17, 2014 at 11:15
1

Edit

It got the issue Actually Price,Special Price,Special Price from date and scope is Website.So it was taking same for value for all stores.As you was change it value for one store then it automatically change to other store.

enter image description here

Solution:

1) If you three store was in different Website then you can change the those attribute enter image description here

It works it store would enter image description here look like:

Full image link : http://oi60.tinypic.com/2j4vt6e.jpg

2) Delete those attribute and create new attribute of same name and proprity and but need Scope label store view

4
  • Hi, I have tried it before. But result is same in both ways. It does not set my special prices to null. Any idea? Thank You
    – umair ayub
    Nov 17, 2014 at 11:19
  • hi will check .. give some time
    – Amit Bera
    Nov 17, 2014 at 14:04
  • hi amit, its not a problem. I have separate website for each store.
    – umair ayub
    Nov 18, 2014 at 6:36
  • I have asked a new question. please read. magento.stackexchange.com/questions/44441/…
    – umair ayub
    Nov 18, 2014 at 7:11

Your Answer

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

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