I\'m having a problem with a third-party ioncube loader encoded feedloader plugin which is no longer supported by the original
This is the solution I eventually used in 'shell/fix_images.php':
addAttributeToFilter('is_imported', 1); // attribute added by importer
$c=0;
foreach($products as $p) {
$pid = $p->getId();
$product = Mage::getModel('catalog/product')->load($pid);
$mediaGallery = $product->getMediaGallery();
if (isset($mediaGallery['images'])){
foreach ($mediaGallery['images'] as $image){
Mage::getSingleton('catalog/product_action')
->updateAttributes(array($pid), array('image'=>$image['file']), 0);
$c++;
break;
}
}
}
echo($c . " product(s) updated.");
}
}
$shell = new Mage_Shell_Updater();
$shell->run();
If anyone should use this, be sure to remove the 'addAttributeToFilter' from your own Mage method chain.. If you are going to run this as a standalone script (without disabling the realtime indexing first), add this code at the beginning of run():
$pCollection = Mage::getSingleton('index/indexer')->getProcessesCollection();
foreach ($pCollection as $process) {
$process->setMode(Mage_Index_Model_Process::MODE_MANUAL)->save();
}
at the end of run():
foreach ($pCollection as $process) {
$process->setMode(Mage_Index_Model_Process::MODE_REAL_TIME)->save();
}
Also, the abstract.php is from Mage_Shell, usually located in the /shell/ directory in the root of your Magento installation.