If you want to add a label to a product image programmatically, you cannot do this with the addImageToMediaGallery method. The following code, however, does the job:
|
1 2 3 4 5 6 |
foreach($product->getData('media_gallery') as $each){ foreach($each as $image){ $attributes = $product->getTypeInstance(true)->getSetAttributes($product); $attributes['media_gallery']->getBackend()->updateImage($product, $image['file'], array('label' => 'whatever')); } } |
Adding a product image label programmatically
Need help implementing this solution, or still looking for a fix to your Magento problem? Get in touch and I will be happy to help with your project.