Magento 1.7缩略图图像不显示 [英] Magento 1.7 Thumbnail Image not Displaying

查看:63
本文介绍了Magento 1.7缩略图图像不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在magento主题的顶部栏上建立一个微型购物车.需要在微型购物车中显示产品缩略图和名称.我已经在目录"checkout/cart"中创建了一个文件top_cart.phtml.使用下面给出的代码.

Building a minicart on top bar in magento theme. Need to show products thumbnail and name in minicart. I have made a file top_cart.phtml in directory "checkout/cart". Using the code given below.

<?php 

$_cartQty = $this->getSummaryCount();
$session = Mage::getSingleton('checkout/session');
if ($_cartQty == 0) : ?>
    <span class="titleBlock">Your shopping cart is empty.</span>
<?php else : 
    foreach($session->getQuote()->getAllItems() as $_item): ?>
    <div>
        <span><?php echo $_item->getThumbnailImage(); ?></span>
        <span><?php echo $_item->getName(); ?></span>
    </div>
    <?php endforeach ?>
<?php endif;?>  
?>

现在可以正确显示名称,但是不显示缩略图.指南plz.

Now the name is shown correctly but the thumbnail images are not being shown. Guide plz.

推荐答案

您需要从产品而不是购物车中获取图像URL.请尝试以下操作:

You need to get the image url from the product and not the cart item. Try the following:

<img src="<?php echo $_item->getProduct()->getThumbnailUrl() ?>" alt="<?php echo $_item->getName() ?>" />

或者,如果您要调整图像的大小或对其进行任何其他操作,请使用目录/图像帮助器.这是获取图像并调整其大小的示例:

Or if you are going to be resizing the image or doing anything else with it then use the catalog/image helper. Here is an example of getting the image and resizing it:

<img src="<?php echo $this->helper('catalog/image')->init($_item->getProduct(), 'thumbnail')->resize(50); ?>" alt="<?php echo $_item->getName() ?>" />

这篇关于Magento 1.7缩略图图像不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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