Magento在购物车中获取产品图片 [英] Magento get product images in shoppping cart

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

问题描述

我正在尝试获取购物车中所有产品的所有产品图片.我使用了以下代码:

I'm trying to get all the product images of all the products in the shopping cart. I've used the following code:

$_item = $this->getItem();
$_product = Mage::getModel('catalog/product')->load($_item->getProductId());

foreach ($_product->getMediaGalleryImages() as $image) {
    echo var_export($image->getUrl());
    echo "<br>";
}

但这仅显示购物车中第一个产品的所有图像.我已经尝试过这种方式:

But this only displays all the images of the first produuct in the shopping cart. I've tried it this way:

foreach ($this->getMediaGalleryImages() as $image) {
    echo var_export($image->getUrl());
    echo "<br>";
}

但这不会返回任何内容.如何获得所有产品的所有图像?

But this doesn't return anything. How can I get all the images of all the products?

推荐答案

使用$this->getProductThumbnail()->resize(50,50)检索缩略图.

使用以下示例从产品中获取不同种类的图像:

Use this example to get a different kind of image from the product:

$_product = $this->getItem()->getProduct();
Mage::helper('catalog/image')->init($_product, 'small_image')->resize(100,100);

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

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