title: Magento : Pagination missing in custom collection
body: <p>I am facing a problem in pagination while displaying a custom collection of products . As I am darn new to Magento please bear with any naivety in my understanding.</p>
  
  <p><strong>Objective :</strong> I want to display Other products from same category on the Product view page and also leveraging the infinite scroll extension which I am using . So that a user will be displayed (say) 5 products on the Product page load but as the user scrolls down, the next page of 5 products will be loaded and displayed. This extension works well on my Category listing page.</p>
  
  <p><strong>The Problem :</strong> I am <strong>able</strong> to display the products on the product page via the below code, the infinite scroll also looks active but the pagination is NOT working. ALL the products from the collection are loaded in a single go so that the infinite scroll on Page 2 shows a repeated list of first page products when user scrolls down. </p>
  
  <p>Will be highly grateful if anyone can help me out with this.</p>
  
  <p>Following is what I wrote :
  <strong>/app/code/local/Mage/Catalog/Block/Product/OtherProducts.php</strong></p>
  
  <pre><code>&lt;?php
  
  class Mage_Catalog_Block_Product_OtherProducts extends Mage_Catalog_Block_Product_List
  {
     protected function _getProductCollection()
     {
        $aCategoryId = $this-&gt;getProduct()-&gt;getCategoryIds();
          if (!$aCategoryId) {
              echo "This product is not assigned to any categories.";
          }
          $iCategoryId = $aCategoryId[0];
          $oCategory = Mage::getModel('catalog/category')-&gt;load($iCategoryId);
          $oProductCollection = $oCategory
              -&gt;getProductCollection()
              -&gt;addCategoryFilter($oCategory)
              -&gt;addAttributeToSelect('*')
              -&gt;addFieldToFilter('entity_id', array('neq' =&gt; $this-&gt;getProduct()-&gt;getId()));
  
  
          return $oProductCollection;
  
     }
  }
  ?&gt;
  </code></pre>
  
  <p><strong>/app/design/frontend/default//layout/catalog.xml</strong>, just after the xml for Product View page.</p>
  
  <pre><code>&lt;reference name="content"&gt;
                     &lt;block type="catalog/product_OtherProducts" name="product_OtherProducts" template="catalog/product/otherslist.phtml"&gt;
                        &lt;action method="setColumnCount"&gt;&lt;columns&gt;5&lt;/columns&gt;&lt;/action&gt;
                        &lt;action method="setProductsCount"&gt;&lt;count&gt;5&lt;/count&gt;&lt;/action&gt;
                        &lt;block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml"&gt;
                           &lt;block type="page/html_pager" name="product_list_toolbar_pager" /&gt;                  
                           &lt;action method="setDefaultGridPerPage"&gt;&lt;limit&gt;10&lt;/limit&gt;&lt;/action&gt;
                           &lt;action method="addPagerLimit"&gt;&lt;mode&gt;grid&lt;/mode&gt;&lt;limit&gt;12&lt;/limit&gt;&lt;/action&gt;
                           &lt;action method="addPagerLimit"&gt;&lt;mode&gt;grid&lt;/mode&gt;&lt;limit&gt;24&lt;/limit&gt;&lt;/action&gt;
                           &lt;action method="addPagerLimit"&gt;&lt;mode&gt;grid&lt;/mode&gt;&lt;limit&gt;36&lt;/limit&gt;&lt;/action&gt;
                           &lt;action method="addPagerLimit"&gt;&lt;mode&gt;grid&lt;/mode&gt;&lt;limit&gt;48&lt;/limit&gt;&lt;/action&gt;
                           &lt;action method="addPagerLimit" translate="label"&gt;&lt;mode&gt;grid&lt;/mode&gt;&lt;limit&gt;all&lt;/limit&gt;&lt;label&gt;All&lt;/label&gt;&lt;/action&gt;
                        &lt;/block&gt;
  
                        &lt;action method="addColumnCountLayoutDepend"&gt;&lt;layout&gt;one_column&lt;/layout&gt;&lt;count&gt;6&lt;/count&gt;&lt;/action&gt;
                        &lt;action method="setToolbarBlockName"&gt;&lt;name&gt;product_list_toolbar&lt;/name&gt;&lt;/action&gt;
                     &lt;/block&gt;
  &lt;/reference&gt;
  </code></pre>
  
  <p><strong>/app/design/frontend/default/roadgods/template/catalog/product/otherslist.phtml</strong></p>
  
  <pre><code>&lt;?php
      $_productCollection=$this-&gt;getLoadedProductCollection();
      $_helper = $this-&gt;helper('catalog/output');
  ?&gt;
  &lt;?php if(!$_productCollection-&gt;count()): ?&gt;
  &lt;p class="note-msg"&gt;&lt;?php echo $this-&gt;__('There are no products matching the selection.') ?&gt;&lt;/p&gt;
  &lt;?php else: ?&gt;
  &lt;div class="category-products"&gt;
  
      &lt;?php 
      echo $this-&gt;getToolbarHtml();
      ?&gt;
      &lt;?php // List mode ?&gt;
      &lt;?php if($this-&gt;getMode()!='grid'): ?&gt;
      &lt;?php $_iterator = 0; ?&gt;
      &lt;ol class="products-list" id="products-list"&gt;
      &lt;?php foreach ($_productCollection as $_product): ?&gt;
          &lt;li class="item&lt;?php if( ++$_iterator == sizeof($_productCollection) ): ?&gt; last&lt;?php endif; ?&gt;"&gt;
              &lt;?php // Product Image ?&gt;
              &lt;a href="&lt;?php echo $_product-&gt;getProductUrl() ?&gt;" title="&lt;?php echo $this-&gt;stripTags($this-&gt;getImageLabel($_product, 'small_image'), null, true) ?&gt;" class="product-image"&gt;&lt;img src="&lt;?php echo $this-&gt;helper('catalog/image')-&gt;init($_product, 'small_image')-&gt;resize(160,200); ?&gt;" width="160" height="200" alt="&lt;?php echo $this-&gt;stripTags($this-&gt;getImageLabel($_product, 'small_image'), null, true) ?&gt;" /&gt;&lt;/a&gt;
              &lt;?php // Product description ?&gt;
              &lt;div class="product-shop"&gt;
                  &lt;div class="f-fix"&gt;
                      &lt;?php $_productNameStripped = $this-&gt;stripTags($_product-&gt;getName(), null, true); ?&gt;
                      &lt;h2 class="product-name"&gt;&lt;a href="&lt;?php echo $_product-&gt;getProductUrl() ?&gt;" title="&lt;?php echo $_productNameStripped; ?&gt;"&gt;
                      &lt;?php echo Mage::helper('commonfun')-&gt;getProductShortName($_helper-&gt;productAttribute($_product, $_product-&gt;getName() , 'name'),0,60); ?&gt;&lt;/a&gt;&lt;/h2&gt;
                    &lt;?php /*?&gt;  &lt;?php if($_product-&gt;getRatingSummary()): ?&gt;
                      &lt;?php echo $this-&gt;getReviewsSummaryHtml($_product) ?&gt;
                      &lt;?php endif; ?&gt;&lt;?php */?&gt;
                      &lt;?php echo $this-&gt;getPriceHtml($_product, true) ?&gt;
                      &lt;?php if($_product-&gt;isSaleable()): ?&gt;
                          &lt;!--&lt;p&gt;&lt;button type="button" title="&lt;?php echo $this-&gt;__('Add to Cart') ?&gt;" class="button btn-cart" onclick="setLocation('&lt;?php echo $this-&gt;getAddToCartUrl($_product) ?&gt;')"&gt;&lt;span&gt;&lt;span&gt;&lt;?php echo $this-&gt;__('Add to Cart') ?&gt;&lt;/span&gt;&lt;/span&gt;&lt;/button&gt;&lt;/p&gt;--&gt;
                      &lt;?php else: ?&gt;
                         &lt;!-- &lt;p class="availability out-of-stock"&gt;&lt;span&gt;&lt;?php echo $this-&gt;__('Sold Out') ?&gt;&lt;/span&gt;&lt;/p&gt;--&gt;
                      &lt;?php endif; ?&gt;
                      &lt;div class="desc std"&gt;
                          &lt;?php echo $_helper-&gt;productAttribute($_product, $_product-&gt;getShortDescription(), 'short_description') ?&gt;
                          &lt;a href="&lt;?php echo $_product-&gt;getProductUrl() ?&gt;" title="&lt;?php echo $_productNameStripped ?&gt;" class="link-learn"&gt;&lt;?php echo $this-&gt;__('Learn More') ?&gt;&lt;/a&gt;
                      &lt;/div&gt;
                      &lt;?php /*?&gt;&lt;ul class="add-to-links"&gt;
                          &lt;?php if ($this-&gt;helper('wishlist')-&gt;isAllow()) : ?&gt;
                              &lt;li&gt;&lt;a href="&lt;?php echo $this-&gt;helper('wishlist')-&gt;getAddUrl($_product) ?&gt;" class="link-wishlist"&gt;&lt;?php echo $this-&gt;__('Add to Wishlist') ?&gt;&lt;/a&gt;&lt;/li&gt;
                          &lt;?php endif; ?&gt;
                          &lt;?php if($_compareUrl=$this-&gt;getAddToCompareUrl($_product)): ?&gt;
                              &lt;li&gt;&lt;span class="separator"&gt;|&lt;/span&gt; &lt;a href="&lt;?php echo $_compareUrl ?&gt;" class="link-compare"&gt;&lt;?php echo $this-&gt;__('Add to Compare') ?&gt;&lt;/a&gt;&lt;/li&gt;
                          &lt;?php endif; ?&gt;
                      &lt;/ul&gt;&lt;?php */?&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/li&gt;
      &lt;?php endforeach; ?&gt;
      &lt;/ol&gt;
      &lt;script type="text/javascript"&gt;decorateList('products-list', 'none-recursive')&lt;/script&gt;
  
      &lt;?php else: ?&gt;
  
      &lt;?php // Grid Mode ?&gt;
  
      &lt;?php $_collectionSize = $_productCollection-&gt;count() ?&gt;
      &lt;?php $_columnCount = $this-&gt;getColumnCount(); ?&gt;
      &lt;?php $i=0; foreach ($_productCollection as $_product): ?&gt;
          &lt;?php if ($i++%$_columnCount==0): ?&gt;
          &lt;div class="productslist_view"&gt;
            &lt;div class="pro_cat"&gt;
          &lt;ul class="products-grid productslist_v-grid"&gt;
          &lt;?php endif ?&gt;
              &lt;li class="item&lt;?php if(($i-1)%$_columnCount==0): ?&gt; first&lt;?php elseif($i%$_columnCount==0): ?&gt; last&lt;?php endif; ?&gt;"&gt;
  
                 &lt;div class="pro2"&gt;
  
                 &lt;?php
                   $price = $_product-&gt;getPrice();
                   $specialprice = $_product-&gt;getFinalPrice();
                   if($specialprice==$price){ }
                   else { 
                      echo '&lt;p class="yellow_price"&gt;';
                      $totalPercent = (($price - $specialprice) *100)/ $price;
                      echo round($totalPercent)."%";
                      echo  '&lt;br /&gt; Off&lt;/p&gt;';
                   }
                  ?&gt;
  
  
               &lt;div class="product_image"&gt;   
               &lt;a href="&lt;?php echo $_product-&gt;getProductUrl() ?&gt;" title="&lt;?php echo $this-&gt;stripTags($this-&gt;getImageLabel($_product, 'small_image'), null, true) ?&gt;" class="product-image"&gt;&lt;img src="&lt;?php echo $this-&gt;helper('catalog/image')-&gt;init($_product, 'small_image')-&gt;keepAspectRatio(TRUE)-&gt;keepFrame(TRUE)-&gt;resize(160,200); ?&gt;" width="160" height="200" alt="&lt;?php echo $this-&gt;stripTags($this-&gt;getImageLabel($_product, 'small_image'), null, true) ?&gt;" /&gt;&lt;/a&gt;
  
               &lt;/div&gt;
  
               &lt;?php
               $sku_gift = $_product-&gt;getData('sku_of_product_gift');
               if(!$sku_gift==''):
                  $prod_gift = Mage::getModel('catalog/product')-&gt;loadByAttribute('sku', $sku_gift);
                  $gift_name = $prod_gift-&gt;getName();
                  $gift_image = Mage::helper('catalog/image')-&gt;init($prod_gift, 'small_image')-&gt;resize(30);
               ?&gt;
  
               &lt;div class="productgiftlist"&gt;
               &lt;a href="&lt;?php echo $_product-&gt;getProductUrl() ?&gt;" title= "&lt;?php echo $gift_name?&gt;" style="color:white"&gt;
                &lt;img src="&lt;?php echo $gift_image ?&gt;" style="float:left;margin:3px;"&gt;&lt;?php echo " + Free ".$gift_name ?&gt;
               &lt;/a&gt;
               &lt;/div&gt;
  
               &lt;?php endif; ?&gt;
  
                 &lt;p class="new_name"&gt;&lt;a href="&lt;?php echo $_product-&gt;getProductUrl() ?&gt;" title="&lt;?php echo $this-&gt;stripTags($_product-&gt;getName(), null, true) ?&gt;"&gt;&lt;?php echo Mage::helper('commonfun')-&gt;getProductShortName($_helper-&gt;productAttribute($_product, $_product-&gt;getName(), 'name'),0,60) ?&gt;&lt;/a&gt;&lt;/p&gt;
                &lt;?php /*?&gt;  &lt;?php if($_product-&gt;getRatingSummary()): ?&gt;
                  &lt;?php echo $this-&gt;getReviewsSummaryHtml($_product, 'short') ?&gt;
                  &lt;?php endif; ?&gt;&lt;?php */?&gt;
              &lt;p style="margin:auto; width:100%; float:left; height:auto; "&gt;&lt;?php echo $this-&gt;getPriceHtml($_product, true) ?&gt; &lt;/p&gt;
              &lt;p style="margin:auto; width:100%; float:left; height:auto; "&gt;
  
                      &lt;?php if($_product-&gt;isSaleable()): ?&gt;
                         &lt;!-- &lt;button type="button" title="&lt;?php echo $this-&gt;__('Add to Cart') ?&gt;" class="button btn-cart" onclick="setLocation('&lt;?php echo $this-&gt;getAddToCartUrl($_product) ?&gt;')"&gt;&lt;span&gt;&lt;span&gt;&lt;?php echo $this-&gt;__('Add to Cart') ?&gt;&lt;/span&gt;&lt;/span&gt;&lt;/button&gt;--&gt;&lt;/p&gt;
                      &lt;?php else: ?&gt;
                        &lt;p style="margin:auto; width:100%; float:left; height:auto; "&gt;   &lt;span&gt;&lt;?php echo $this-&gt;__('Sold Out') ?&gt;&lt;/span&gt;&lt;/p&gt;
                      &lt;?php endif; ?&gt;
                   &lt;p style="margin:auto; width:100%; float:left; height:auto; "&gt;     &lt;ul class="add-to-links"&gt;
                          &lt;?php if ($this-&gt;helper('wishlist')-&gt;isAllow()) : ?&gt;
                              &lt;li&gt;&lt;a href="&lt;?php echo $this-&gt;helper('wishlist')-&gt;getAddUrl($_product) ?&gt;" class="link-wishlist"&gt;&lt;?php echo $this-&gt;__('Add to Wishlist') ?&gt;&lt;/a&gt;&lt;/li&gt;
                          &lt;?php endif; ?&gt;
                          &lt;?php if($_compareUrl=$this-&gt;getAddToCompareUrl($_product)): ?&gt;
                             &lt;!-- &lt;li&gt;&lt;span class="separator"&gt;|&lt;/span&gt; &lt;a href="&lt;?php echo $_compareUrl ?&gt;" class="link-compare"&gt;&lt;?php echo $this-&gt;__('Add to Compare') ?&gt;&lt;/a&gt;&lt;/li&gt;--&gt;
                          &lt;?php endif; ?&gt;
                      &lt;/ul&gt;
                 &lt;/p&gt;
  
  
                  &lt;/div&gt;
  
  
  
              &lt;/li&gt;
          &lt;?php if ($i%$_columnCount==0 || $i==$_collectionSize): ?&gt;
          &lt;/ul&gt;
          &lt;/div&gt;
          &lt;/div&gt;
          &lt;?php endif ?&gt;
          &lt;?php endforeach ?&gt;
          &lt;script type="text/javascript"&gt;decorateGeneric($$('ul.products-grid'), ['odd','even','first','last'])&lt;/script&gt;
      &lt;?php endif; ?&gt;
  
      &lt;!--&lt;div class="toolbar-bottom"&gt;
          &lt;?php /*echo $this-&gt;getToolbarHtml()*/ ?&gt;
      &lt;/div&gt;--&gt;
  &lt;/div&gt;
  &lt;?php endif; ?&gt;
  </code></pre>
  
  <p>Can anyone please help me out with this please , would be highly grateful.</p>