0
<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"/> </block> 

The above represents the pagination of a product collection. It displays page size, products per page, current (and next, previous, etc) page, sort action, etc. Normally i'd call this with a getChild( ) call.

Now, how can I recreate the above function call in something like a widget? Where I must use other methods than the layout.xml and getChild calls to generate blocks.

For example:

$this->_pager = $this->getLayout() ->createBlock('catalog/product_list_toolbar')->setTemplate('catalog/product/list/toolbar.phtml'); 

This accomplishes the first part of the block/template call.

and:

$this->_pager = $this->getLayout() ->createBlock('page/html_pager', 'product_list_toolbar_pager'); 

This accomplishes the second part of the block/template call.

How can I combine these two related pieces of functionality? I need to return them with a toHtml( ) function call.

4
  • What are you trying to accomplish? Product collection pagination and related display is terribly bungled and coupled in Magento 1, and recreating this functionality is problematic at best. Commented Feb 25, 2015 at 18:03
  • @benmarks display product collection pagination for a custom product collection within a widget. Using 'only' the first part makes a call to the second part using getchild( ), which, if you've worked with widgets, doesn't really work. If I only use the second part then the sorting toolbar section is left out. My only functioning workaround is to take the 'guts' of each and put them together within the widget itself. Commented Feb 25, 2015 at 18:15
  • I assume you're wanting to do this in a widget because you want an admin interface with some input(s) which will be used to define the params of the product collection? Commented Feb 25, 2015 at 19:13
  • @benmarks bingo. We're generating a cms page for every category, sale, new products, other_random_things, etc. page and this widget will take parameters from the cms page to retrieve custom product collections. Commented Feb 25, 2015 at 19:25

1 Answer 1

1

I'm pretty sure that you can get what you need by looking at the new products widget (Mage_Catalog_Block_Product_Widget_New). All you need to do is setProductCollection() with a collection of your choosing.

1
  • awesome, but the layered navigation now is not functional. Commented Mar 2, 2015 at 14:57

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.