I have a Magento store that has around 3,000 products. Almost all of these products have a single image attached to it.
For some reason, even though I set the small image and thumbnail image as the same as the base image in the import CSV file, only the base image is set for each product. This means that when you search for a product you get a placeholder - but once you go into the product page you get the correct image. This can be easily remedied by going into the product admin page and selecting the boxes for small image and thumbnail.
The problem is, with 3,000 images this would take quite a long time to do manually. I have found a SQL command that should make all base, small and thumbnail images map the the first image for each product. As I only have one image for each product this should be perfect. However, it doesn't do anything. It says 0 rows changed.
UPDATE catalog_product_entity_media_gallery AS mg,
catalog_product_entity_media_gallery_value AS mgv,
catalog_product_entity_varchar AS ev
SET ev.value = mg.value
WHERE mg.value_id = mgv.value_id
AND mg.entity_id = ev.entity_id
AND ev.attribute_id IN (70, 71, 72)
AND mgv.position = 1
Does anyone know why this isn't working?
Thanks,
Danny
After making a change like that to the database, even if successful, you would need to rebuild the images cache in Cache Management.
You might be able to do it with a script like this and not worry about caching or indexing.
<?php
require 'app/Mage.php';
Mage::app();
$products = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*');
foreach ($products as $product) {
if (!$product->hasImage()) continue;
if (!$product->hasSmallImage()) $product->setSmallImage($product->getImage());
if (!$product->hasThumbnail()) $product->setThumbnail($product->getImage());
$product->save();
}
?>Done!
Save this in your Magento directory and access it by typing the URL into your browser's address bar. I haven't tested this script yet.