我正在搜索相同内容并找到此代码
$product->getMediaGallery('images');
获取所有图片 including excluded images 的产品。我没有测试上面的代码,但我需要的是只获取被排除的图像。有什么办法吗?另外,如何从标签中选择图像?
答案 0 :(得分:3)
$prod = 4542;
$product = Mage::getModel('catalog/product')->load($prod);
foreach ($product->getMediaGallery('images') as $img) {
if ($img['disabled'] == 1) {
var_dump($img['label']);
}
}
答案 1 :(得分:2)
http://magentotutorialbeginners.blogspot.in/2014/03/get-product-image-from-label-magento.html
您可以通过这种方式从标签中排除图像
$image= Mage::getModel('catalog/product')->load($_product->getId())->getMediaGalleryImages();
$_images = $image->getItemByColumnValue('label', 'YOUR_LABEL');
编辑 获取排除图片
查看class Mage_Catalog_Model_Product extends Mage_Catalog_Model_Abstract
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);
}