Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- error_reporting(E_ALL);
- ini_set('display_errors', 1);
- require_once 'app/Mage.php';
- Mage::app();
- Mage::app()->getStore()->setId(Mage_Core_Model_App::ADMIN_STORE_ID);
- $arr = array(
- array("sku"=>"SKU###","file"=>"76763.jpg"),
- array("sku"=>"SKU###","file"=>"76133.jpg"),
- array("sku"=>"SKU###","file"=>"76931.jpg"),
- array("sku"=>"SKU###","file"=>"76703.jpg"),
- array("sku"=>"SKU###","file"=>"77239_1.jpg"),
- array("sku"=>"SKU###","file"=>"77239.jpg"),
- array("sku"=>"SKU###","file"=>"75296.jpg"),
- array("sku"=>"SKU###","file"=>"77261_1.jpg"),
- array("sku"=>"SKU###","file"=>"76422.jpg"),
- array("sku"=>"SKU###","file"=>"76759.jpg"),
- array("sku"=>"SKU###","file"=>"76344.jpg"),
- array("sku"=>"SKU###","file"=>"73661.jpg"),
- array("sku"=>"SKU###","file"=>"77261.jpg"),
- array("sku"=>"SKU###","file"=>"76426_1.jpg"),
- );
- $importDir = Mage::getBaseDir('media') . DS . 'import' . DS;
- foreach($arr as $val){
- $sku = $val['sku'];
- $image = $val['file'];
- $filePath = $importDir.$image;
- $product = Mage::getModel('catalog/product')->loadByAttribute('sku',$sku);
- if(file_exists($filePath)){
- $product->addImageToMediaGallery($filePath, null, false, false);
- echo "done";
- $product->save();
- } else {
- echo $productSKU . " not done";
- }
- echo "<br>";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement