$_products = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSelect('*');
$count=0;
foreach ($_products as $_product) {
$_product->load();
$attributes = $_product->getTypeInstance(true)->getSetAttributes($_product);
if (!isset($attributes['media_gallery'])) echo 'No Media Gallery Found';
$images = $_product->getMediaGalleryImages();
$gallery = $attributes['media_gallery']->getBackend();
foreach ($images as $image) {
if (strlen($image->getLabel()) > 0) continue;
$gallery->updateImage($_product, $image->getFile(), array('label' => $_product->getName()));
$count++; if ($count > 10) break;
}
$_product->setData('media_gallery', $gallery);
$_product->save();
}
// Also tried
//$_product->getResource()->saveAttribute($_product, 'media_gallery');
// Also tried to just $image->setLabel('label') inside the loop
Gets the label just fine, but never saves. For about 1200 items, this code takes 11 minutes so limited to test the first 10.
This script init's using the admin store, and our main store is '1'.
If can't get an answer, gonna just start using sql.