Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your Block should be like this:</p> <pre><code>class Mage_Catalog_Block_Product_Mostviewed extends Mage_Catalog_Block_Product_Abstract { public function __construct(){ parent::__construct(); $storeId = Mage::app()-&gt;getStore()-&gt;getId(); $collection = Mage::getResourceModel('reports/product_collection') -&gt;addViewsCount(); $collection-&gt;getSelect()-&gt;joinInner(array('e2' =&gt; 'catalog_product_flat_'.$storeId), 'e2.entity_id = e.entity_id'); $this-&gt;setProductCollection($collection); } protected function _prepareLayout() { parent::_prepareLayout(); $pager = $this-&gt;getLayout()-&gt;createBlock('page/html_pager', 'mostview.pager') -&gt;setCollection($this-&gt;getProductCollection()); $this-&gt;setChild('pager', $pager); $this-&gt;getProductCollection()-&gt;load(); return $this; } public function getPagerHtml() { return $this-&gt;getChildHtml('pager'); } } </code></pre> <p>Your template should be like this:</p> <pre><code>&lt;?php $_collection = $this-&gt;getProductCollection(); ?&gt; &lt;!-- top pagination --&gt; &lt;?php echo $this-&gt;getPagerHtml(); ?&gt; &lt;?php if($_collection-&gt;getSize()): ?&gt; ... &lt;?php foreach ($_collection as $_item): ?&gt; ... &lt;?php endforeach; ?&gt; &lt;?php endif ?&gt; &lt;!-- bottom pagination --&gt; &lt;?php echo $this-&gt;getPagerHtml(); ?&gt; </code></pre> <p>If you want to display toolbar. Your block should be like this: (NOTE: I didn't test this code)</p> <pre><code>class Mage_Catalog_Block_Product_Mostviewed extends Mage_Catalog_Block_Product_Abstract { public function __construct(){ parent::__construct(); $storeId = Mage::app()-&gt;getStore()-&gt;getId(); $collection = Mage::getResourceModel('reports/product_collection') -&gt;addViewsCount(); $collection-&gt;getSelect()-&gt;joinInner(array('e2' =&gt; 'catalog_product_flat_'.$storeId), 'e2.entity_id = e.entity_id'); $this-&gt;setProductCollection($collection); } protected function _prepareLayout() { parent::_prepareLayout(); $toolbar = $this-&gt;getLayout()-&gt;createBlock('catalog/product_list_toolbar', microtime()) -&gt;setCollection($this-&gt;getProductCollection()); $pager = $this-&gt;getLayout()-&gt;createBlock('page/html_pager', microtime()); $toolbar-&gt;setChild('product_list_toolbar_pager', $pager); $this-&gt;setChild('toolbar', $toolbar); $this-&gt;getProductCollection()-&gt;load(); return $this; } public function getPagerHtml() { return $this-&gt;getChildHtml('toolbar'); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload