magento中自定义集合的分页问题
我创建了自定义块来从多个类别中检索产品。我已将此块扩展到核心产品列表块。分页器不适用于自定义集合,知道为什么分页不起作用吗? 我在 collection.php 中使用这个函数
public function addCategoriesFilter($categories)
{
$alias = 'cat_index';
$categoryCondition = $this->getConnection()->quoteInto(
$alias.'.product_id=e.entity_id AND '.$alias.'.store_id=? AND ',
$this->getStoreId()
);
$categoryCondition.= $alias.'.category_id IN ('.$categories.')';
$this->getSelect()->group('e.entity_id');
$this->getSelect()->joinInner(
array($alias => $this->getTable('catalog/category_product_index')),
$categoryCondition,
array('position'=>'position')
);
$this->_categoryIndexJoined = true;
$this->_joinFields['position'] = array('table'=>$alias, 'field'=>'position' );
return $this;
}
I have created custom block to retrieve product from multiple categories. I have extended this block to core product List block. Pager is not working on custom collection, have any idea why paging is not working?
I am using this function in collection.php
public function addCategoriesFilter($categories)
{
$alias = 'cat_index';
$categoryCondition = $this->getConnection()->quoteInto(
$alias.'.product_id=e.entity_id AND '.$alias.'.store_id=? AND ',
$this->getStoreId()
);
$categoryCondition.= $alias.'.category_id IN ('.$categories.')';
$this->getSelect()->group('e.entity_id');
$this->getSelect()->joinInner(
array($alias => $this->getTable('catalog/category_product_index')),
$categoryCondition,
array('position'=>'position')
);
$this->_categoryIndexJoined = true;
$this->_joinFields['position'] = array('table'=>$alias, 'field'=>'position' );
return $this;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
经过几个小时的探索并阅读了几乎所有有关自定义集合分页的论坛后,我找到了一种显示自定义集合页面分页的方法。
我需要显示我的页面的工具栏,该工具栏将显示糖尿病值为“是”的产品(糖尿病是自定义属性)。
首先我们需要过滤 phtml 文件上的集合:
After exploring many hours and reading almost all forums for paging on custom collection I have found a way to show paging for custom collection page.
I have a requirement to show toolbar for my page that will show products which are having diabetic value as yes (diabetic is the custom attribute).
Firstly we need to filter the collection on phtml file:
<
block type="page/html_pager" name="product_list_toolbar_pager" />
这需要添加到您尝试加载产品的 xml 块中,以便它获取工具栏和分页器。
请参阅此链接作为参考。
带分页的产品
<block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
<block type="page/html_pager" name="product_list_toolbar_pager" />
This needs to be added to the xml block where you are attempting to load product so that it gets the toolbar and the pager.
See this link as reference.
Products with Pagination