cancel
Showing results for 
Search instead for 
Did you mean: 

Set all images as default Magento 1.9.2

Set all images as default Magento 1.9.2

I have a problem.
All images are not shown in Greek Store view (neither to others)
How can I set them all as default?

 

Untitled-2.jpg

1 REPLY 1

Re: Set all images as default Magento 1.9.2

Hi @Alfapromo,



You can create a shell script that associates the first image as the base/thumbnail/small image for the product, and then run the shell script through the command-line.

 

Here is sample code for you:

 

$product = Mage::getModel('catalog/product')->load($productId);

// Get all images
$mediaGallery = $product->getMediaGallery();

// Check if there are images
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($product->getId()), array('image'=>$image['file']), 0);
        //stop
        break;
    }

 

 

Always remember to create a backup before running a shell script that modifies your catalog.

 

 

Best regards.
Gabriel

Welcome to the Magento Forums. Remember to introduce yourself and read the Magento Forums Guidelines.