Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6078093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:47:40+00:00 2026-05-23T10:47:40+00:00

I am having trouble with a module that is supposed to update prices on

  • 0

I am having trouble with a module that is supposed to update prices on a per-website basis.

At the top of my module I have :

Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);

This should mean that when I call the module (the module has a frontend) I am able to update prices etc as ‘admin’. However, this just isn’t happening. Currently I have gone on a few desperate efforts to get it working – seeing if number formats trip it up or indexes not reindexed, cache problems and anything else.

The following snippet actually produces the right numbers but it just is not saving to the database. Any ideas?

$product = Mage::getModel('catalog/product')->
           setStoreId($storeId)->setWebsiteId($websites[$store])->
           loadByAttribute('sku',$price['SKU']);
$oldprice=(float)str_replace(",","",$product->getPrice());

if($newprice!=$oldprice) {
    Mage::log($product->getPrice());
    $product->setPrice(number_format($newprice,4,".",""));
    Mage::log($product->getPrice());
    $product->getResource()->saveAttribute($product, 'price');
    $product->save();
    Mage::log($product->getPrice());
    unset($product);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T10:47:41+00:00Added an answer on May 23, 2026 at 10:47 am

    Let’s assume that you are updating the prices of products using a method in your module’s class, with the following sample code:-

    public function updateProductPrices ($sku, $newPrice) {
        Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
    
        $websites = Mage::app()->getWebsites();
    
        $product = Mage::getModel('catalog/product')
        $productId = $product->getIdBySku($sku);
    
        foreach ($websites as $_eachWebsite) {
            $_websiteId = $_eachWebsite->getWebsiteId();
    
            $websiteObj = new Mage_Core_Model_Website();
            $websiteObj->load($_websiteId);
    
            $storeIds = $websiteObj->getStoreIds();
    
            if (count($storeIds)) {
                foreach ($storeIds as $_eachStoreId) {
                    $product->setStoreId($_eachStoreId)
                            ->load($productId);
    
                    $oldPrice = $product->getPrice();
    
                    if ($oldPrice != $newPrice) {
                        $product->setPrice($newPrice);
                        $product->save();
                    }
                }
            }
    
            unset($storeIds, $websiteObj, $_websiteId);
        }
    
        unset($product);
    }
    

    Hope it helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I’m having a lot of trouble understanding how to create a module that will
I'm having some trouble with my script. It's supposed to open a website trough
I'm having trouble finding a joomla module that displays articles on rows and columns,
I'm trying to learn python and I'm having trouble importing a module. I have
I am having trouble figuring one of several error messages that seem to have
I am having trouble including a module in a namespaced class. The example below
I am having trouble with the Python multiprocessing module. I am using the Process
I'm having trouble replacing a function from a different module with another function and
I'm using the python optparse module in my program, and I'm having trouble finding
I'm trying to build a proxy module for .NET, but I'm having trouble copying

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.