I have imported 77K products in magento with custom import script.
All data are imported successfully.
The mistake I did is I forgot to set Thumbnail image for each product.
We have only two images for each product, so I want to set small image value same as thumbnail image.
Is there anyone who can provide me code to update thumbnail for each product at a time?
I have tried this:
$products = Mage::getModel('catalog/product')->getCollection();
foreach ($products as $product) {
if (!$product->hasThumbnail()) $product->setThumbnail($product->getSmallImage());
$product->save();
}
Not saving thumbnail 🙁
Also tried this:
$value=$product->getData('small_image');
if ($value) {
Mage::getSingleton('catalog/product_action')
->updateAttributes(array($product->getId()),
array(
'image'=>$value,
'small_image'=>$value,
'thumbnail'=>$value,
),
0); // 0 specifies the Default
}
But when I try to update each product in loop Getting this error:
Mage registry key "_singleton/" already exists error
Best Answer