Hi!
I uploaded 16000 products with SOAP api and I have a problem with images.
The images are not shown in the fronted because they are not set as default. I tried to make them default but unfortunately all of them are set in order 0
How Can i set the all to 1 or set them as default?
Hi @Alfapromo,
You have to loop through all the products and set the first image as the image to be displayed for the product.
Here is a sample code:
$productId = 1;
//load the product
$product = Mage::getModel('catalog/product')->load($productId);
//get all images
$mediaGallery = $product->getMediaGallery();
//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;
}
}
Best regards.
Gabriel
Hello and thanks for the response.
In which file I will add this code?