![](/img/trans.png)
[英]How to set my custom URL for product collection in Magento custom module?
[英]How to Set Product Count in Magento Custom Module?
嗨,我已經嘗試了好幾個小時,以簡單地設置暢銷書模塊中顯示的產品數量。 沒運氣!
我已經搜索並沒有在網上找到針對此特定問題的答案。
這個網站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"> </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; ?>
謝謝
您可以通過添加$this->getItemCollection()->getSelect()->limit(40)
將集合的大小限制為例如40。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.