Our brands

Answer for file exists not working

Hello,
 
Please try to use the code:
 
if(!empty($value[14])){
$galleryData = explode(‘,’,$value[14]);
$simpleProduct->setMediaGallery (array(‘images’=>array (), ‘values’=>array ()));
foreach($galleryData as $gallery_img) {
$imgUrl = Mage::getBaseDir().$gallery_img;
if (file_exists($imgUrl)){
$simpleProduct->addImageToMediaGallery($gallery_img, array (‘image’,’small_image’,’thumbnail’), false, false);
}else{
echo “else part”. $gallery_img = ‘media/import/no_image.jpg’;
$simpleProduct->addImageToMediaGallery($gallery_img, array (‘image’,’small_image’,’thumbnail’), false, false);
}
}
}

Share this Post!

Panda Thuan
Panda Thuan
Creativity is falling in love with the world
Do NOT follow this link or you will be banned from the site!