我在产品模板(view.phtml(中,我有一个带有图像ID的数组。如何从ID中检索文件名或路径??谢谢1
简单地说,
$array_ids = //your array of ids
$images = $_product->getMediaGalleryImages();
foreach($array_ids as $id) {
foreach($images as $image) {
if($id == $image['id']) {
//do stuff here
}
}
}
提示:var_dump($_product->debug())
要检索主图像路径,可以使用以下方法:
$_product->getImage()
$_product->getSmallImage()
$_product->getThumbnail()
要检索库图像的集合,请使用$_product->getMediaGalleryImages()
。将此集合的成员作为$image
进行迭代,可以调用$image->getPath()
。参见Mage_Catalog_Model_Product->getMediaGalleryImages()
。