Webkul
Services
Technologies Bagisto QloApps
iOS Android SAP BigCommerce Wix
Trusted by
Samsung Intel Toyota Walmart Disney Nokia Nestlé Decathlon
See all customers
Back to Top
DOC

Magento Set default image from product images

Get filename from here
<?php
$_product = Mage::getModel('catalog/product')->load($ProductId)->getMediaGalleryImages();
foreach ($_product as $value) {
     if($value->getFile() == $yourfilename){
        $newimage = $value->getFile(); //get your file you want to set
     }
}
?>
Now set your default image
<?php
$objprod=Mage::getModel('catalog/product')->load($ProductId);
$objprod->setSmallImage($newimage); //newimage is filename you want to set
$objprod->setImage($newimage);
$objprod->setThumbnail($newimage);
$objprod->save();
?>
. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

Back to Top

Message Sent!

If you have more details or questions, you can reply to the received confirmation email.

Back to Home