dqhsv0147421 2013-04-03 12:25
浏览 30
已采纳

magento同类产品缩略图

I have 3 products in the same categoy
I'm trying to display same category products thumbnails in magento catalog/product/view.phtml

<?php
    $productCollection = Mage::getModel('catalog/category')->load($cat_id)
         ->getProductCollection()
         ->addAttributeToSelect('*')
         ->addAttributeToFilter('status', 1);

    $prodIds = $productCollection->getAllIds();

    $prod_siblings = array();
    foreach($prodIds as $productId) 
    {
        $prod =  Mage::getModel('catalog/product')->load($productId);
        $prod_siblings[] = array(
            'url' => $prod->getProductUrl(),
            'name' => $prod->getName(),
            'image' => $this->helper('catalog/image')->init($prod, 'thumbnail')->constrainOnly(TRUE)->keepAspectRatio(TRUE)->keepFrame(FALSE)->resize(75)
            );
    }
?>

with this code, the 3 $prod_siblings have their own name and url (stored in the array), but they are all sharing the same image (the image of the last created product).

  • 写回答

2条回答 默认 最新

  • douyuanliao8815 2013-04-03 13:47
    关注

    Got it !

    found my answer here : How to get a product's image in Magento?

    used (string)Mage::helper('catalog/image')->init($prod, 'thumbnail')...

    instead of $this->helper('catalog/image')->init($prod, 'thumbnail')...

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?