开发者

How do I find out if product has a product image?

开发者 https://www.devze.com 2023-02-11 20:53 出处:网络
To get the image src in a template file the following code is used: $this->helper(\'catalog/image\')->init($_product, \'small_image\')->resize(200,100);

To get the image src in a template file the following code is used:

$this->helper('catalog/image')->init($_product, 'small_image')->resize(200,100);

But how开发者_JAVA技巧 can I find out if there is an image associated with the product or if the placeholder image will be used?

(Magento v. 1.4.2)


Placeholder is always used if product dosen't have image.

You can check those methods:

$product->getSmallImage();
$product->getThumbnail();
$product->getImage();

If product has image those moethod will return path.

Or you can check this method

$product->getMediaGalleryImages();

UPDATE 14.10.2011

no_selection is set when you check in BO > Product Edit Page > Images 'No image' chackbox


Best solution is:

if($_product->getImage() && $_product->getImage() != 'no_selection'){//do}
0

精彩评论

暂无评论...
验证码 换一张
取 消