My question more broad at the beginning but I will go more into detail later. I have around 3000 products where I have the Skus and prices in a .csv file. Now the prices changed recently and I would like to upload/update these prices of the products. Is there a quick way to do this via a script using the SOAP API?

Or is there an easier way around this?

UPDATE I have used this function http://www.blog.magepsycho.com/updating-product-prices-in-magento-in-easier-faster-way/ but now the value and price mismatch. Are there any better options going through a csv and then match the prices for each sku to a price.


I don't think that using the SOAP services will get you what you need fast. I mean it will probably work, but it will be really slow for 3k products.
Instead try this script.
Let's say that your csv has 2 columns. SKU and price.

$skuIndex = 0;
$priceIndex = 1;
$csv = 'path/to/file.csv';
$io = new Varien_Io_File();
//an array to keep the products by price
$productIdsByPrice = array();
//a product model instance
$productModel = Mage::getSingleton('catalog/product');
//read the csv
$io->streamOpen($csv, 'r+');
while($csvData = $io->streamReadCsv()){
   if (count($csvData) < 2) { //skip rows with less than 2 columns
   $sku = trim($csvData[$skuIndex]);
   //get the product id by sku
   $id = $productModel->getIdBySku($sku);
   if ($id) {
      //if the id exists then mark it for update
      $price = trim($csvData[$priceIndex]);
      if (!isset($productIdsByPrice[$price])) {
         $productIdsByPrice[$price] = array();
      $productIdsByPrice[$price][] = $id;
//now you should have the product ids you need to update grouped by price
//just do the fast update
foreach ($productIdsByPrice as $price => $ids) {
        $ids, //what products to update
        array('price' => $price), //what attributes to update
        0 //store id for update

you can place this code in one of your custom models or helpers and then run it. You may want to double check the code. I haven't tested it. Also backup your db.


If you run this from a file, create one called price_update.php on the same level as index.php and add this in it:

error_reporting(E_ALL | E_STRICT);
define('MAGENTO_ROOT', getcwd()); 
$mageFilename = MAGENTO_ROOT . '/app/Mage.php'; 
require_once $mageFilename; 
ini_set('display_errors', 1);

After this, add the code from above that parses the csv and call in your browser MAGE_ROOT/price_update.php.

  • Ok that looks great. Would it be possible to call that from a php file or not?
    – Klettseb
    Mar 3 '15 at 9:57
  • 1
    I edited the answer.
    – Marius
    Mar 3 '15 at 10:01
  • I get a Internal Server Error 500. I´m trying to figure out why
    – Klettseb
    Mar 3 '15 at 10:35
  • Hey Marius, do you have any idea why I would get that Internal Server Error 500 when i try to use the Php file?
    – Klettseb
    Mar 4 '15 at 8:24
  • I don't know. Like I said I haven't tested the code. Try doing a step by step debug and see the line that fails.
    – Marius
    Mar 4 '15 at 8:30

enter image description hereJust created availability, price, cost CSV-updater. Interested in development or contribution, so posting it here.

http://lycenok.com/magento-extensions/magento-csv-product-updater.html https://github.com/lycenok/magento_csv_product_updater

Regards, Eugene.

UPDATE: Remember about the simple solution, implemented in Magento itself.

System -> Import/Export -> "Dataflow - profiles"

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.