title: Getting the first collection item without breaking pager
body: <p>I posted a question about this earlier, but I have more information now and I thought it best to post a new one rather than modify (sorry if that's not proper protocol).  You can find my original question <a href="https://stackoverflow.com/questions/6311646/magento-collection-catch-22/">here</a>.</p>
  
  <p>Anyhow, the initial problem was that I wanted to inspect the first item in a collection inside the List.php class just after setting the collection so that I could scrape the category and use that to show reviews.  This was all based off a custom module, so there were a lot of variables.  I have since tried it on a default Magento sample store and only added <strong>ONE</strong> line to <code>app/code/core/Mage/catalog/Block/Product/List.php</code> to break the pager.  Here are the details.  If you have any ideas why this is happening, please let me know as I'm stuck</p>
  
  <p>First, open <code>app/code/core/Mage/catalog/Block/Product/List.php</code> and locate the <code>_getProductCollection</code> function.  At the end of the <code>if (is_null...)</code> block, add <code>$_foo123 = $this-&gt;_productCollection-&gt;getFirstItem();</code> so you have a function that looks like this:</p>
  
  <pre><code>protected function _getProductCollection()
  {
      if (is_null($this-&gt;_productCollection)) {
          $layer = $this-&gt;getLayer();
          /* @var $layer Mage_Catalog_Model_Layer */
          if ($this-&gt;getShowRootCategory()) {
              $this-&gt;setCategoryId(Mage::app()-&gt;getStore()-&gt;getRootCategoryId());
          }
  
          // if this is a product view page
          if (Mage::registry('product')) {
              // get collection of categories this product is associated with
              $categories = Mage::registry('product')-&gt;getCategoryCollection()
              -&gt;setPage(1, 1)
              -&gt;load();
              // if the product is associated with any category
              if ($categories-&gt;count()) {
                  // show products from this category
                  $this-&gt;setCategoryId(current($categories-&gt;getIterator()));
              }
          }
  
          $origCategory = null;
          if ($this-&gt;getCategoryId()) {
              $category = Mage::getModel('catalog/category')-&gt;load($this-&gt;getCategoryId());
              if ($category-&gt;getId()) {
                  $origCategory = $layer-&gt;getCurrentCategory();
                  $layer-&gt;setCurrentCategory($category);
              }
          }
          $this-&gt;_productCollection = $layer-&gt;getProductCollection();
  
          $this-&gt;prepareSortableFieldsByCategory($layer-&gt;getCurrentCategory());
  
          if ($origCategory) {
              $layer-&gt;setCurrentCategory($origCategory);
          }
  
          //THIS LINE BREAKS THE PAGER
          $_foo123 = $this-&gt;_productCollection-&gt;getFirstItem();
      }
  
      return $this-&gt;_productCollection;
  }
  </code></pre>
  
  <p>Now, simply go to any product list that uses that class (category view, for instance) and you'll see what I mean.  No matter what you choose under <strong>Show XX per page</strong> in the toolbar, it will always show you all items in the list.  If you comment out that <code>$_foo123...</code> line, it works fine.</p>
  
  <p>What gives??</p>
  
  <p><em>P.S.  I know I'm not supposed to edit core files...this is just an example :)</em></p>