Reputation: 5959
I was searching for same and found this code
$product->getMediaGallery('images');
to get all images including excluded images of products. I'd not tested the above code but what I need is to get only the excluded images. Is there any way? Also, how can I select images from label?
Upvotes: 1
Views: 2115
Reputation: 11533
http://magentotutorialbeginners.blogspot.in/2014/03/get-product-image-from-label-magento.html
you can exclude the image from label this way
$image= Mage::getModel('catalog/product')->load($_product->getId())->getMediaGalleryImages();
$_images = $image->getItemByColumnValue('label', 'YOUR_LABEL');
EDIT to get exclude image
When you look at class Mage_Catalog_Model_Product extends Mage_Catalog_Model_Abstract
in getMediaGalleryImages()
if(!$this->hasData('media_gallery_images') && is_array($this->getMediaGallery('images'))) {
$images = new Varien_Data_Collection();
foreach ($this->getMediaGallery('images') as $image) {
if ($image['disabled']) {
continue; ***//HERE Magento remove disbale image so you can hack this or override this***
}
$image['url'] = $this->getMediaConfig()->getMediaUrl($image['file']);
$image['id'] = isset($image['value_id']) ? $image['value_id'] : null;
$image['path'] = $this->getMediaConfig()->getMediaPath($image['file']);
$images->addItem(new Varien_Object($image));
}
$this->setData('media_gallery_images', $images);
}
Upvotes: 2
Reputation: 1003
$prod = 4542;
$product = Mage::getModel('catalog/product')->load($prod);
foreach ($product->getMediaGallery('images') as $img) {
if ($img['disabled'] == 1) {
var_dump($img['label']);
}
}
Upvotes: 3