title: how implement setPagesize for pagination, right now returning all products
body: <p>All I am trying to setPageSize() on collection so that I can use that for Pagination. </p>
  
  <p>I am getting all the products returned no matter what integer I put into the setPageSize.</p>
  
  <p>Code:</p>
  
  <pre><code>    &lt;?php
  
  class Rik_Featured_Block_Featured extends
  Mage_Core_Block_Template {
  
      private $_itemPerPage = 2;
      public $_category_id = '' ;
      private $_currentPage = '';
  
      public function __construct() {
          $custom_var_code = Mage::getModel('core/variable')-&gt;loadByCode('homepage_firstrow_prod');
          if(isset($custom_var_code)) echo $this-&gt;_category_id = $custom_var_code-&gt;getValue('text') ;
          echo $page_var = $this-&gt;getRequest()-&gt;getParam('p');
          if(isset($page_var)&amp;&amp;$page_var!=0){           
              $this-&gt;_currentPage = $page_var;
          }
          if(isset($page_var)&amp;&amp;$page_var == '0'){           
              $this-&gt;_currentPage = '1';
          }
  
  
      }
  
  
      /****************** Here is my setcurpage and setpagesize************************/
  
          public function allProducts() {
          $collection = $this-&gt;_getCollection();
          echo 'col is'.$collection-&gt;count();
          /*Setting current page and page size */
          $collection-&gt;setCurPage(1);
          $collection-&gt;setPageSize($this-&gt;_itemPerPage);
          return $collection;
      }
  
          private function _getCollection() {
  
          $category = Mage::getModel('catalog/category')-&gt;load($this-&gt;_category_id);
  
          if($category-&gt;getUrlPath() != NULL) {
  
              $collection = $category-&gt;getProductCollection();
  
  
              //Mage::helper('catalog/product')-&gt;setSkipSaleableCheck(true);
              $collection-&gt;addWebsiteFilter();
              $collection-&gt;addUrlRewrite($this-&gt;_category_id);
              $collection-&gt;addMinimalPrice()-&gt;addFinalPrice()-&gt;addTaxPercents();
              Mage::getSingleton('catalog/product_visibility')
                      -&gt;addVisibleInCatalogFilterToCollection($collection);
              Mage::getSingleton('catalog/product_status')
                      -&gt;addVisibleFilterToCollection($collection);
              $collection-&gt;addAttributeToSelect(array('entity_id', 'sku', 'name', 'short_description', 
                  'description', 'price', 'thumbnail', 'image', 'url_path', 'type_of'));
  
             return $collection;
          }
          else { echo 'cat does not exit';}
        }
  
  
  
  
      public function totalPages() {       
  
          $_collections_count = $this-&gt;_getCollection()-&gt;count();
          return $number_of_pages = ceil($_collections_count / $this-&gt;_itemPerPage);
      }
  
  
  
  }
  </code></pre>
  
  <p>Also is it a good idea to use the __constructor the way I am using in this block?</p>
  
  <p>Thank you.</p>