我通过
获得了产品的所有图像Mage::getModel('catalog/product')->load($prod->getId())->getMediaGalleryImages()->getItems();
以下是一个项目的内容:
<i>protected</i> '_data' <font color='#888a85'>=></font>
<b>array</b> <i>(size=11)</i>
'value_id' <font color='#888a85'>=></font> <small>string</small> <font color='#cc0000'>'204'</font> <i>(length=3)</i>
'file' <font color='#888a85'>=></font> <small>string</small> <font color='#cc0000'>'/m/a/magento-red-furniture-set.jpg'</font> <i>(length=34)</i>
'label' <font color='#888a85'>=></font> <small>string</small> <font color='#cc0000'>'test label'</font> <i>(length=10)</i>
'position' <font color='#888a85'>=></font> <small>string</small> <font color='#cc0000'>'0'</font> <i>(length=1)</i>
'disabled' <font color='#888a85'>=></font> <small>string</small> <font color='#cc0000'>'0'</font> <i>(length=1)</i>
'label_default' <font color='#888a85'>=></font> <small>string</small> <font color='#cc0000'>'test label'</font> <i>(length=10)</i>
'position_default' <font color='#888a85'>=></font> <small>string</small> <font color='#cc0000'>'0'</font> <i>(length=1)</i>
'disabled_default' <font color='#888a85'>=></font> <small>string</small> <font color='#cc0000'>'0'</font> <i>(length=1)</i>
'url' <font color='#888a85'>=></font> <small>string</small> <font color='#cc0000'>'http://work.my/m1702/media/catalog/product/m/a/magento-red-furniture-set.jpg'</font> <i>(length=76)</i>
'id' <font color='#888a85'>=></font> <small>string</small> <font color='#cc0000'>'204'</font> <i>(length=3)</i>
'path' <font color='#888a85'>=></font> <small>string</small> <font color='#cc0000'>'/var/www/m1702/media/catalog/product/m/a/magento-red-furniture-set.jpg'</font> <i>(length=70)</i>
如果此图像项目是基本图像(或小图像,缩略图),如何检入代码?
答案 0 :(得分:9)
试试这个。
if ($item->getFile() == $product->getImage()){
//then it's image
}
if ($item->getFile() == $product->getSmallImage()){
//then it's small image
}
if ($item->getFile() == $product->getThumbnail()){
//then it's thumbnail
}
请记住,它可以是全部3个。