Magento Coding Solutions

magento add product image programmatically

<?php
$productId=1;
$newProduct= Mage::getModel('catalog/product')->load($productId);

                    /*myimage*/
           
                $previewImage= Mage::getBaseDir().'/images/designs/1_0.png';
                if(file_exists($previewImage)){
                                $newProduct->setMediaGallery (array('images'=>array (), 'values'=>array ()));
                                $newProduct->addImageToMediaGallery ($previewImage, array ('thumbnail','small_image','image'), false, false);
                                }                     
                            }           
                                   
               
                $newProduct->save();
               
                ?>

No comments:

Post a Comment