Mass update magento products sku

This tutorial explains how to mass update magento products sku. The following code updates the sku based on the old magento products sku.

Please click here to see the tutorial which gives step by step explanation for bulk update magento products sku.

function rewriteSku($newDatas) {
    $i = 1;
    foreach($newDatas as $newData) {
        $product = Mage::getModel('catalog/product')->loadByAttribute('sku', $newData[1]);
        if($product) { 
            $product->setSku($newData[0]);
            $product->save();
            echo  $i++.' '.$product->getName() . ' SKU updated';
            echo "\n";
        }
    }
      
}

Share this Tutorial