我想在这里展示一些分页。它显示了60种产品。我怎样才能在每个页面上显示20个?
谢谢
//$_productCollection = $this->getLoadedProductCollection();
$_helper = $this->helper('catalog/output');
$resource = Mage::getSingleton('core/resource');
$readConnection = $resource->getConnection('core_read');
//$query = 'SELECT cid FROM tees_user_login_table WHERE ((group_id = 1 and status = 1 and cid > 0) or (group_id in (2,3,4,5) and include_new = 1 and status = 1))';
$query = 'SELECT cid FROM tees_user_login_table WHERE status = 1 and include_new = 1';
$results = $readConnection->fetchAll($query);
$categoryIds = array() ;
foreach ($results as $k => $v) {
$categoryIds[] = $v['cid'] ;
}
$this->setProductsCount(60) ;
$_productCollection = $this
->getProductCollection()
->setPageSize($this->getProductsCount())
->addAttributeToSelect(array(
'name',
'price',
'special_price',
'sku',
'small_image'
))
->joinField('category_id', // add category ID field to collection
'catalog_category_product',
'category_id',
'product_id=entity_id',
null,
'left'
)
->groupByAttribute('sku')
->addAttributeToFilter('category_id', array('in' => $categoryIds));
答案 0 :(得分:1)
试试这个。
将$this->setProductsCount(60) ;
替换为$this->setProductsCount(20) ;
。
或者你想要的任何价值。
$this->setProductsCount(60) ;
用于控制查询的限制->setPageSize($this->getProductsCount())
,可能还有页面的布局。
最后,并且与问题没有直接关系, Magento 进行此类修改的方式将在块中。