如何在Magento定制模块中设置产品数量?

时间:2012-12-31 05:36:54

标签: magento count product

您好我已经花了好几个小时来设置畅销模块中显示的产品数量。没有运气!

我已经搜索过,并且没有在网上找到这个特定问题的答案。

这个网站http://www.jimcode.org/2011/04/magento-setting-columns-limiting-products-shown-grid/接近但我只是没有得到它。

这是“我的”代码:

<?php if($this->getItemCollection() && $this->getItemCollection()->getSize()): ?>
<div class="block">
    <div class="block-title">
        <strong><span><?php echo $this->__('Top Sellers In This Category') ?></span></strong>
    </div>
    <div class="block-content">
    <?php  $this->setColumnCount(1); // uncomment this line if you want to have another number of columns ?>
    <?php $this->resetItemsIterator() ?>
    <?php for($_i=0;$_i<$this->getRowCount();$_i++): ?>
        <tr>
        <?php for($_j=0;$_j<$this->getColumnCount();$_j++): ?>
            <?php if($_link=$this->getIterableItem()): ?>
                            <div class="img" style="float:left;width:212px">
                                <a href="<?php echo $_link->getProductUrl() ?>"><img src="<?php echo $this->helper('catalog/image')->init($_link, 'small_image')->constrainOnly(TRUE)->keepAspectRatio(TRUE)->keepFrame(FALSE)->resize(193); ?>" width="193" height="" alt="<?php echo $this->htmlEscape($_link->getName()) ?>" /></a>                                                                          
                            </div>
                            <div class="text" style="float:left;width:212px;margin-top:-60px"><img  style="width:45px;height:64px;position:relative;z-index:15;right:0px;bottom:260px" src="<?php echo $this->getSkinUrl('images/ribbon.png'); ?>" />
                                <div class="title"><a href="<?php echo $_link->getProductUrl() ?>"><?php echo $this->htmlEscape($_link->getName()) ?></a></div>
                                No: <?php echo $this->htmlEscape($_link->getSku()) ?>
                                <div class="price"></div>
                                <a href="<?php echo $this->getAddToCartUrl($_link) ?>" class="arr">Add to Cart</a>
                            </div>
                <?php else: ?>
                <td class="empty-product">&nbsp;</td>
                <?php endif; ?>
        <?php endfor; ?>
        </tr>
<?php
/*        <?php if($_i+2<=$this->getRowCount()): ?>
            <tr>
                <td class="spacer" colspan="6"><div class="separatorsmall"></div></td>
            </tr>
          <?php endif; ?>
*/
?>    <?php endfor; ?>
    </div>
</div>
<?php endif; ?>

谢谢

1 个答案:

答案 0 :(得分:0)

您可以将集合的大小限制为例如40添加$this->getItemCollection()->getSelect()->limit(40)