0

I have a list of 400+ SKU updates that I received for my client from one of the brands they sell. Not all of the SKUs in the list are on the site...for the ones that aren't on the site, I don't want them to be added, I just want the ones it finds to be changed. Is that clear enough? I don't have enough time to individually check for them.

Here's what I need: a php script that loads a .csv, runs it against the database, checks to see if the SKU exists...if it does, then swap it out with new one. If it doesn't find the SKU, it either ignores it or makes note of it & continues on. (so far every script I found spits out an error if even just one SKU isn't found in the database)

I have a script that has similar functionality for updating prices, but I don't know the database well enough to know what I should be targeting, so I'm hesitant to try to mod it & use it (I'm still getting my feet wet with Magento).

PS - I'm using Magento 1.7.0.2 CE

HAROONMIND
  • 103
  • 7

3 Answers3

0

Take a look @ How to create an array from a CSV file using PHP and the fgetcsv function

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

$file = fopen('myCSVFile.csv', 'r');
while (($line = fgetcsv($file)) !== FALSE) {
    //$line is an array of the csv elements
    print_r($line);

    $productModel->getIdBySku($line);

    if($productModel->getId()){
      //found 
      //update product
      $productModel->setData('','');
      $productModel->save();
    } 
    $productModel->reset()
}
fclose($file);
Community
  • 1
  • 1
MagePal Extensions
  • 17,646
  • 2
  • 47
  • 62
0

Check out Magmi, ( http://sourceforge.net/projects/magmi/ ) you might be able to do what you need with that.

mable
  • 144
  • 7
0

Actually, I found this simple solution, it was exactly what I needed & wanted. Tested against the local site & then ran it against the live site...worked perfectly! Thanks for your help though!

http://magentofresher.wordpress.com/2013/08/12/magento-programmatically-updating-skus-in-bulk/