您可以如下创建自定义块并设置分页如here
<?php echo $this->getLayout()->createBlock('yourmodule/product_customlist')->setTemplate('catalog/product/list.phtml')->toHtml() ?>
更新
app/etc/modules/Custom_Products.xml
如下
<config>
<modules>
<Custom_Products>
<active>true</active>
<codePool>local</codePool>
</Custom_Products>
</modules>
</config>
app/code/local/Custom/Products/etc/config.xml
文件如下
<config>
<global>
<blocks>
<customproducts>
<class>Custom_Products_Block</class>
</customproducts>
</blocks>
</global>
</config>
app/code/local/Custom/Products/Block/Customlist.php
文件如下
<?php
class Custom_Products_Block_Customlist extends Mage_Core_Block_Template
{
protected function _construct()
{
parent::_construct();
// We get our collection through our model
$this->_collection = Mage::getModel('catalog/category')->load($category_id)
->getProductCollection()
->addAttributeToSelect('*') // add all attributes - optional
->addAttributeToFilter('status', 1) // enabled
->addAttributeToFilter('visibility', 4) //visibility in catalog,search
->setOrder('price', 'ASC'); //sets the order by price
// Instantiate a new Pager block
$pager = new Mage_Page_Block_Html_Pager();
// We set our limit (here an integer store in configuration).
// /!\ The limit must be set before the collection
$pager
->setLimit(5)
->setCollection($this->_collection);
// Add our Pager block to our current list block
$this->setChild('pager', $pager);
}
}
?>
app/design/YOUR_PACKAGE/YOUR_THEME/template/catalog/product/customlist.phtml
如下
<?php
$_productCollection=$this->_collection;
...
your products code here
...
?>
<?php
echo $this->getChildHtml('pager');
?>
检查它是否适合你。