Reputation: 3554
need to update the product thumbnail , small image and base image programatically
for this i a using a below code
$collection1->addImageToMediaGallery($importDir,$mediaArray,false);
//$collection1->setStoreId(0);
$collection1->save();
if (isset($mediaGallery['images'])){
//loop through the images
foreach ($mediaGallery['images'] as $image){
//set the first image as the base image
Mage::getSingleton('catalog/product_action')->updateAttributes(array($collection1->getId()), array('image'=>$image['file'],'thumbnail'=>$image['file'],'small_image'=>$image['file']), 0);
//stop
break;
}
}
with this code a
image adding to the gallery
but i need to set the latest image to set as image and base image
.Please suggest how can i achieve this thanks
Upvotes: 2
Views: 3134
Reputation: 2443
check below url
http://www.blog.magepsycho.com/how-to-import-product-images-from-external-url-in-magento/
hope this help you
Upvotes: 1