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?

Screenshot: enter image description here

I have tried this:

$products = Mage::getModel('catalog/product')->getCollection();
foreach ($products as $product) {
    if (!$product->hasThumbnail()) $product->setThumbnail($product->getSmallImage());

Not saving thumbnail :(

Also tried this:

if ($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

1 Answer 1

require 'app/Mage.php';
$products = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*');
foreach ($products as $product) {
    if (!$product->hasImage()) continue;
    if (!$product->hasThumbnail()) {
  • Getting error : Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 74 bytes) in D:\wamp\www\sdwheel\lib\Zend\Db\Statement\Pdo.php on line 290 Commented Aug 29, 2016 at 11:54
  • Increase memory size in .htaccess file to : php_value memory_limit 1024M Commented Aug 29, 2016 at 11:57
  • In wampserver php.ini says max_execution_time = 500000 Commented Aug 29, 2016 at 11:57
  • The value is ` memory_limit = 1000M` Commented Aug 29, 2016 at 11:59
  • May we its not able to load all product collection because you have lots of product. So in that case use limit in collection and only load those product which don't have thumbnail attribute set with filter condition Commented Aug 29, 2016 at 12:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.