开发者

Adding pager to custom collection block

Sorry for the redundancy of this question, but none of the example and solutions have worked for me. I have a custom module that extends Mage_Catalog_Block_Product_List. The only function in it is _getProductCollection which sets the product collection based on which attribute you want to filter on. It's pretty simple and there are no layout updates involved. I put the block on the page by putting the following into the Content section of a CMS page:

{{block type="vps_featured/list" name="vps_featured_list" attribute_name="best_sellers" template="catalog/product/sale_list.phtml"}}

Since it extends Mage_Catalog_Block_Product_List, I get all the bells and whistles for a product list page, including the toolbar. However, the pager isn't there. I've tried a number of different suggestions but none have helped.

I looked in Toolbar.php in the core code and found where it calls getPagerHtml. I put some debug 开发者_StackOverflow社区statements in there and determined that it calls this function when putting my custom block on the page but $this->getChild('product_list_toolbar_pager') is not returning the block, presumably because it isn't there. I tried adding the block using a layout update XML file and adding the <frontend><layout><updates>... tags to my config, but this didn't seem to do anything.

I have Alan Storm's CommerceBug extension, so I pulled that up and exported the layout XML for the page. It doesn't contain any toolbar block at all, despite the fact that the toolbar is on the page and only the pager isn't working. If I do the same thing on a category landing page, it shows the toolbar block in the layout xml. So I've clearly missed something here, but I'm at a loss as to what. I hope someone can help :)

Brian


As it turns out, the solution found HERE works great! You have to add the block using the Layout Update XML rather than adding it in the content section. I still don't quite understand why, but it works.


There already was question about Getting pager to show on magento list

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜