0

In Magento, I have a page where I'm hard coding the images of certain products. Rather than simply using the products' image URLs to do so, I'd like to use dynamic references to the products' associated images so that if I change the product's image, the reference on this page won't break. I need both thumbnail size images and large images. Does anyone know how to do this?

4

1 回答 1

0

假设您已经可以访问产品对象$_product

$thumbImageUrl =  Mage::helper('catalog/image')->init($_product, 'small_image')->resize($width, $height);
$imageUrl =  Mage::helper('catalog/image')->init($_product, 'image')->resize($width, $height);
// if you don't want to resize at all
$imageUrl = $_product->getMediaConfig()->getMediaUrl($_product->getData('image'));
于 2013-03-12T02:24:28.320 回答