我想在我的产品页面上显示分页。请检查我的代码,
这是我的控制者:
$model = Mage::getModel('catalog/product')->getCollection()
->addAttributeToSelect(array('name', 'descryption'))
->setPageSize(10);
$numberOfPages = $model->getLastPageNumber();
$data['products'] = $model->setCurPage($i)->load();
这是我的观点:
<div id="sectionA3" class="tab-pane fade">
<?php
foreach ($data['products'] as $product) {
$productName = $product->getName();
$productImage = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB, true) . "media/catalog/product" .$product->getImage();
?>
<div class="celeb-post" id="products-listing">
<img src="<?php echo $productImage ?>" alt="celeb" />
<div class="hover-image-bg">
<a href="#"><img src="<?php echo $this->getSkinUrl() ?>whi/assets/images/heart.png"></a>
<a href="#"><img src="<?php echo $this->getSkinUrl() ?>whi/assets/images/bag.png"></a>
<a href="#"> <img src="<?php echo $this->getSkinUrl() ?>whi/assets/images/move.png"></a>
<a href="#"><img src="<?php echo $this->getSkinUrl() ?>whi/assets/images/assign.png"></a>
</div>
<div style="clear:both; height:10px;"></div>
<div class="celeb-name-title ucase clearfix brand-pro-title" style="text-align:center;">
<?php
if (strlen($productName) > 20) {
$prostringCut = substr($productName, 0, 20);
$productstring = substr($prostringCut, 0, strrpos($prostringCut, ' ')).'...';
echo $productstring;
}
else{
echo $productName;
}
?></div>
</div>
<?php
}
?>
</div>
如何在我的产品底部添加分页,每页仅显示15个产品。请帮帮我
答案 0 :(得分:0)
参考Mage / Catalog / Block / Product / List.php文件进行收集 和phtml文件请参阅catalog / product / list.php文件
您可以获得所有内容,以便在前端展示您的产品 它可能对你有所帮助。