Image 我能';无法正确获取magento随机产品列表图像和数据

Image 我能';无法正确获取magento随机产品列表图像和数据,image,magento,product,Image,Magento,Product,我的问题是,我可以得到正确的产品url,但它不能得到产品名称、图片、价格和描述 我有6项随机产品块,如下所示: 所有这六个项目都是可点击的,它们都有正确的随机产品url的后面。只是不明白为什么图像、价格和名称不会出现 当前代码: <?php $_productCollection = Mage::getModel('catalog/product')->getCollection(); ?> <?php if(!$_productCollection-&

我的问题是,我可以得到正确的产品url,但它不能得到产品名称、图片、价格和描述

我有6项随机产品块,如下所示:

所有这六个项目都是可点击的,它们都有正确的随机产品url的后面。只是不明白为什么图像、价格和名称不会出现

当前代码:

    <?php $_productCollection = Mage::getModel('catalog/product')->getCollection(); ?>
    <?php if(!$_productCollection->count()): ?>
        <div class="padder">
            <div class="note-msg">
                <?php echo $this->__('There are no products matching the selection.') ?>
            </div>
        </div>
    <?php else: ?>
        <div class="listing-type-cell  catalog-listing padder"  style="margin-bottom:-20px;margin-top:10px;border-top: 1px solid rgba(221,221,221,0.53);"> <!-- the class name will change to .listing-type-grid if viewing in grid mode -->
        <?php $_collectionSize = $_productCollection->count() ?>

        <?php $_items = $_productCollection->getItems(); 
            shuffle($_items); ?>
        <h2 style="margin:20px 0;">Seda toodet vaadanud inimesed vaatasid ka neid tooteid</h2>
        <table cellspacing="0" class="products-grid" id="product-grid-table">
            <?php $i=0; foreach ($_items as $_product): ?>
                <?php if ($i++%6==0): ?>
            <tr height="290">
                <?php endif ?>
                <td class="random_item" style="width:150px;padding-right:10px;">
                    <a class="product-image" href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_product->getName() ?>">
                        <img src="<?php echo $_product->getImageUrl(); ?>" width="144" height="216" alt="<?php echo $this->htmlEscape($_product->getName()) ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>" /></a>
                        <h3 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>"><?php echo $this->htmlEscape($_product->getName()) ?></h3>
                        <?php echo $this->getPriceHtml($_product, true) ?>
                    </a>
                </td>
            <?php if ($i%12==0 && $i!=$_collectionSize): ?>
            </tr>
            <?php endif ?>
            <?php if ($i==6) break;  // show 6 products max ?> 

        <?php endforeach ?>
        <?php for($i;$i%12!=0;$i++): ?>
            <td class="empty-product">&nbsp;</td>
        <?php endfor ?>
        <?php if ($i%12==0): ?>
        </tr>
        <?php endif ?>
        </table>
        <script type="text/javascript">decorateTable('product-grid-table')</script>
    </div>
    <?php endif; ?>

塞达·图德·瓦达努德·瓦塔希德·卡内德·图泰德
可装饰('product-grid-table')

有关添加名称和价格的问题,请参见此问题:有关图片,请参见此线程:

谢谢!我刚刚添加了以下行:$\u productCollection->addAttributeToSelect('name');$\u productCollection->addAttributeToSelect(“价格”)$_productCollection->addAttributeToSelect('image');它解决了这个问题。