2016-07-13 23 views
0

私はここでページネーションをいくつか表示しようとしています。それは60の製品を示しています。たとえば、各ページに20を表示するにはどうすればよいですか?Magentoページ区切り

おかげ

//$_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

このファイルはどこですか? phtml?ブロックは何ですか? –

+0

new.phtml {block type = "catalog/product_new" limit = "48" template = "カタログ/製品/ new.phtml"}} –

+0

正解にするために私の答えに何が追加できますか? –

答えて

1

はこれを試してみてください。

$this->setProductsCount(60) ;$this->setProductsCount(20) ;に置き換えます。

または任意の値を入力します。


$this->setProductsCount(60) ;

は、クエリの制限、 ->setPageSize($this->getProductsCount())、およびページの、おそらくレイアウトを制御するために使用されます。


最後に、との質問に直接関係のない、Magentoの方法が変更のこのタイプは、ブロックになるようにします。