在Magento获取基本产品图片 [英] Get base product image in Magento

查看:526
本文介绍了在Magento获取基本产品图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Magento中获得基本产品图片以调整其大小并显示在购物车边栏中。

I want to get base product image in Magento to resize it and display in cart sidebar.

不幸的是:

echo $this->helper('catalog/image')->init($_product, 'image')->resize(38, 38);

打印Magento占位符图片。

prints Magento placeholder image.

Base正确设置此产品的图像。小图片和缩略图效果很好。

Base image is set for this product properly. Small image and thumbnail works great.

不知道发生了什么。

编辑:
解决方案:
以这种方式获取完整的产品数据:

Solution: Get full product data this way:

$_product = Mage::getModel('catalog/product')->load($_item->getProduct()->getId());

然后根据需要使用它:

echo $this->helper('catalog/image')->init($_product, 'image')->resize(38, 38);


推荐答案

我认为你在寻找:

echo Mage::getModel('catalog/product_media_config')
        ->getMediaUrl( $product->getImage() ); //getSmallImage(), getThumbnail()

应该给予BenMarks 给出了这个回答

这篇关于在Magento获取基本产品图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆