我使用的是Magento社区版本1.5.1.0。
我需要得到一个有形象或没有形象的产品。如果产品没有图像,我们希望指定其类别图像,而不是magento默认图像。
我怎样才能找到有没有图像的产品?
发布于 2012-05-03 17:08:50
$product->getImage();使用上面的代码,如果产品有或者返回关键字"no_selection“,它就会给出图像
if($product->getImage() == 'no_selection')
{
// PRODUCT HAVE NO IMAGE
}
else
{
// PRODUCT HAVE IMAGE
}有了这个,我们就可以找出图片是不是为产品上传的。
发布于 2012-05-03 19:21:37
使用以下代码
<?php
ini_set('display_errors','on');
require_once 'app/Mage.php';
Mage::app('default');
$products = Mage::getModel('catalog/product')->load(1); //Product ID
echo "<pre>";
//print_r($products);
echo $products->getImage();
echo "<br>";
echo $products->getSmallImage();
echo "<br>";
echo $products->getThumbnail();
echo "<br>";
echo Mage::helper('catalog/image')->init($products, 'small_image')->resize(163,100); // resize function is used to resize image
echo "<br>";
echo Mage::helper('catalog/image')->init($products, 'image')->resize(400,400);
?>发布于 2012-05-03 14:58:20
尝尝这个
if ($_product->getImage() != 'no_selection' && $_product->getImage()){put your category image retrive code }https://stackoverflow.com/questions/10426210
复制相似问题