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);
- $importDir = Mage::getBaseDir('media') . DS . 'import' . DS;
- $productsData = array('2abc.jpg','2def.jpg');
- $productSKU = 'SKU';
- $product = Mage::getModel('catalog/product')->loadByAttribute('sku',$productSKU);
- foreach($productsData as $fileName){
- $filePath = $importDir.$fileName;
- if(file_exists($importDir . $fileName)){
- $product->addImageToMediaGallery($importDir . $fileName, null, false, false);
- echo "done";
- } else {
- echo $productSKU . " not done";
- echo "<br>";
- }
- }
- $product->save();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement