title: Can't get product name from Magento product collection
body: <p>I am simply trying to retrieve a products name as well as other basic information from a <code>product collection</code> in <code>Magento</code> but just get errors or null returned. This is with a view to creating my own featured product block.</p>
  
  <p>I am trying to do this from within the home page (created specifically, rather than using the pre-built 1-column/2-column etc):</p>
  
  <pre><code>app\design\frontend\default\eyt2012\template\page\homepage.phtml
  </code></pre>
  
  <p>Within my home page, I am loading the collection like so</p>
  
  <pre><code>$category = new Mage_Catalog_Model_Category();
  $category-&gt;load(236);
  $_productCollection = $category-&gt;getProductCollection();
  </code></pre>
  
  <p>Then I am borrowing the code within <code>&lt;ul&gt;</code> from <code>list.phtml</code>, which I know works:</p>
  
  <pre><code>app\design\frontend\default\eyt2012\template\catalog\product\list.phtml
  </code></pre>
  
  <p>to output all the products in a collection in a nice grid format with images, titles and prices.</p>
  
  <p>Altogether I have so far:</p>
  
  <pre><code>&lt;div class="featured-products"&gt;
      Products of the week    
  
      &lt;?php    
          $category = new Mage_Catalog_Model_Category();
          $category-&gt;load(236);
          $_productCollection = $category-&gt;getProductCollection();    
      ?&gt;   
  
          &lt;ul class="products-grid"&gt;    
  
              &lt;?php $_collectionSize = $_productCollection-&gt;count() ?&gt;
              &lt;?php $_columnCount = 5 ?&gt;
              &lt;?php 
                  $i=0; foreach ($_productCollection as $_product): 
                  $i++;
              ?&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;
  
                          1
  
                          &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;span class="placeholder"&gt;&lt;/span&gt;
                              &lt;img src="&lt;?php echo $this-&gt;helper('catalog/image')-&gt;init($_product, 'small_image')-&gt;resize(155); ?&gt;" alt="&lt;?php echo $this-&gt;stripTags($this-&gt;getImageLabel($_product, 'small_image'), null, true) ?&gt;" /&gt;
                          &lt;/a&gt;
  
                          2
  
                          &lt;?php if ($_product-&gt;getbrands()):?&gt;
                              &lt;span class="brandname"&gt;&lt;?php echo $_product-&gt;getAttributeText('brands') ?&gt;&lt;/span&gt;
                          &lt;?php endif;?&gt;
  
                          3  ! Code currently gets to here before error occurs
  
  
                          &lt;h2 class="product-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 $_helper-&gt;productAttribute($_product, $_product-&gt;getName(), 'name') ?&gt;&lt;/a&gt;&lt;/h2&gt;
  
                          4
                          &lt;?php echo $this-&gt;getPriceHtml($_product, true) ?&gt;
  
                          5
  
                          &lt;div class="actions"&gt;
  
                              &lt;?php if($_product-&gt;isSaleable()): ?&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;?php else: ?&gt;
  
                                  &lt;p class="availability out-of-stock"&gt;&lt;span&gt;&lt;?php echo $this-&gt;__('Out of stock') ?&gt;&lt;/span&gt;&lt;/p&gt;
  
                              &lt;?php endif; ?&gt;
  
                          &lt;/div&gt;
  
  
  
  
                      &lt;/li&gt;
  
                  &lt;?php endforeach ?&gt;
  
              &lt;/ul&gt;
  
  
  
  
  &lt;/div&gt;
  </code></pre>
  
  <p>which is essentially just the code from list.phtml, except my own product collection is used.</p>
  
  <p>I have put numbers after each block of functionality in the above code to test what is causing the error. Currently it gets to 3 then stops.</p>
  
  <p>Can anyone tell me why the <code>$_product-&gt;getName()</code> fails to work, along with the others in that block?</p>
  
  <p>Any help would be appreciated. Thanks.</p>
  
  <p>EDIT:</p>
  
  <p>var_dump of $_productCollection</p>
  
  <pre><code>object(Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection)[337]
    protected '_flatEnabled' =&gt; 
      array (size=1)
        1 =&gt; boolean false
    protected '_productWebsiteTable' =&gt; string 'catalog_product_website' (length=23)
    protected '_productCategoryTable' =&gt; string 'catalog_category_product' (length=24)
    protected '_addUrlRewrite' =&gt; boolean false
    protected '_urlRewriteCategory' =&gt; string '' (length=0)
    protected '_addMinimalPrice' =&gt; boolean false
    protected '_addFinalPrice' =&gt; boolean false
    protected '_allIdsCache' =&gt; null
    protected '_addTaxPercents' =&gt; boolean false
    protected '_productLimitationFilters' =&gt; 
      array (size=3)
        'category_id' =&gt; string '236' (length=3)
        'category_is_anchor' =&gt; int 1
        'store_id' =&gt; string '1' (length=1)
    protected '_productCountSelect' =&gt; null
    protected '_isWebsiteFilter' =&gt; boolean false
    protected '_priceDataFieldFilters' =&gt; 
      array (size=0)
        empty
    protected '_map' =&gt; 
      array (size=1)
        'fields' =&gt; 
          array (size=6)
            'price' =&gt; string 'price_index.price' (length=17)
            'final_price' =&gt; string 'price_index.final_price' (length=23)
            'min_price' =&gt; string 'price_index.min_price' (length=21)
            'max_price' =&gt; string 'price_index.max_price' (length=21)
            'tier_price' =&gt; string 'price_index.tier_price' (length=22)
            'special_price' =&gt; string 'price_index.special_price' (length=25)
    protected '_storeId' =&gt; string '1' (length=1)
    protected '_itemsById' =&gt; 
      array (size=0)
        empty
    protected '_staticFields' =&gt; 
      array (size=6)
        'entity_id' =&gt; string 'entity_id' (length=9)
        'entity_type_id' =&gt; string 'entity_type_id' (length=14)
        'attribute_set_id' =&gt; string 'attribute_set_id' (length=16)
        'type_id' =&gt; string 'type_id' (length=7)
        'created_at' =&gt; string 'created_at' (length=10)
        'updated_at' =&gt; string 'updated_at' (length=10)
    protected '_entity' =&gt; 
      object(Mage_Catalog_Model_Resource_Eav_Mysql4_Product)[165]
        protected '_productWebsiteTable' =&gt; string 'catalog_product_website' (length=23)
        protected '_productCategoryTable' =&gt; string 'catalog_category_product' (length=24)
        protected '_attributes' =&gt; 
          array (size=0)
            empty
        protected '_read' =&gt; 
          object(Varien_Db_Adapter_Pdo_Mysql)[90]
            protected '_transactionLevel' =&gt; int 0
            protected '_connectionFlagsSet' =&gt; boolean true
            protected '_ddlCache' =&gt; 
              array (size=1)
                ...
            protected '_bindParams' =&gt; 
              array (size=2)
                ...
            protected '_bindIncrement' =&gt; int 2
            protected '_debug' =&gt; boolean false
            protected '_logQueryTime' =&gt; float 0.05
            protected '_logAllQueries' =&gt; boolean false
            protected '_logCallStack' =&gt; boolean false
            protected '_debugFile' =&gt; string 'var/debug/sql.txt' (length=17)
            protected '_debugIoAdapter' =&gt; null
            protected '_debugTimer' =&gt; int 0
            protected '_cacheAdapter' =&gt; 
              object(Varien_Cache_Core)[13]
                ...
            protected '_isDdlCacheAllowed' =&gt; boolean true
            protected '_pdoType' =&gt; string 'mysql' (length=5)
            protected '_numericDataTypes' =&gt; 
              array (size=16)
                ...
            protected '_defaultStmtClass' =&gt; string 'Zend_Db_Statement_Pdo' (length=21)
            protected '_config' =&gt; 
              array (size=12)
                ...
            protected '_fetchMode' =&gt; int 2
            protected '_profiler' =&gt; 
              object(Zend_Db_Profiler)[20]
                ...
            protected '_defaultProfilerClass' =&gt; string 'Zend_Db_Profiler' (length=16)
            protected '_connection' =&gt; 
              object(PDO)[17]
                ...
            protected '_caseFolding' =&gt; int 0
            protected '_autoQuoteIdentifiers' =&gt; boolean true
            protected '_allowSerialization' =&gt; boolean true
            protected '_autoReconnectOnUnserialize' =&gt; boolean false
        protected '_write' =&gt; string 'catalog_write' (length=13)
        protected '_type' =&gt; 
          object(Mage_Eav_Model_Entity_Type)[123]
            protected '_attributes' =&gt; null
            protected '_attributesBySet' =&gt; 
              array (size=0)
                ...
            protected '_sets' =&gt; null
            protected '_eventPrefix' =&gt; string 'core_abstract' (length=13)
            protected '_eventObject' =&gt; string 'object' (length=6)
            protected '_resourceName' =&gt; string 'eav/entity_type' (length=15)
            protected '_resource' =&gt; null
            protected '_resourceCollectionName' =&gt; string 'eav/entity_type_collection' (length=26)
            protected '_cacheTag' =&gt; boolean false
            protected '_dataSaveAllowed' =&gt; boolean true
            protected '_isObjectNew' =&gt; null
            protected '_data' =&gt; 
              array (size=16)
                ...
            protected '_hasDataChanges' =&gt; boolean true
            protected '_origData' =&gt; null
            protected '_idFieldName' =&gt; string 'entity_type_id' (length=14)
            protected '_isDeleted' =&gt; boolean false
        protected '_attributesById' =&gt; 
          array (size=0)
            empty
        protected '_attributesByCode' =&gt; 
          array (size=0)
            empty
        protected '_attributesByTable' =&gt; 
          array (size=0)
            empty
        protected '_staticAttributes' =&gt; 
          array (size=0)
            empty
        protected '_entityTable' =&gt; string 'catalog_product_entity' (length=22)
        protected '_describeTable' =&gt; 
          array (size=0)
            empty
        protected '_entityIdField' =&gt; string 'entity_id' (length=9)
        protected '_valueEntityIdField' =&gt; null
        protected '_valueTablePrefix' =&gt; null
        protected '_isPartialLoad' =&gt; boolean false
        protected '_isPartialSave' =&gt; boolean false
        protected '_sortingSetId' =&gt; null
        protected '_attributeValuesToDelete' =&gt; 
          array (size=0)
            empty
        protected '_attributeValuesToSave' =&gt; 
          array (size=0)
            empty
    protected '_selectEntityTypes' =&gt; 
      array (size=0)
        empty
    protected '_selectAttributes' =&gt; 
      array (size=0)
        empty
    protected '_filterAttributes' =&gt; 
      array (size=0)
        empty
    protected '_joinEntities' =&gt; 
      array (size=0)
        empty
    protected '_joinAttributes' =&gt; 
      array (size=0)
        empty
    protected '_joinFields' =&gt; 
      array (size=0)
        empty
    protected '_conn' =&gt; 
      object(Varien_Db_Adapter_Pdo_Mysql)[90]
        protected '_transactionLevel' =&gt; int 0
        protected '_connectionFlagsSet' =&gt; boolean true
        protected '_ddlCache' =&gt; 
          array (size=1)
            1 =&gt; 
              array (size=1)
                ...
        protected '_bindParams' =&gt; 
          array (size=2)
            ':_mage_bind_var_1' =&gt; string '2012-09-26 14:11:06' (length=19)
            ':_mage_bind_var_2' =&gt; string '2012-09-26 14:11:06' (length=19)
        protected '_bindIncrement' =&gt; int 2
        protected '_debug' =&gt; boolean false
        protected '_logQueryTime' =&gt; float 0.05
        protected '_logAllQueries' =&gt; boolean false
        protected '_logCallStack' =&gt; boolean false
        protected '_debugFile' =&gt; string 'var/debug/sql.txt' (length=17)
        protected '_debugIoAdapter' =&gt; null
        protected '_debugTimer' =&gt; int 0
        protected '_cacheAdapter' =&gt; 
          object(Varien_Cache_Core)[13]
            protected '_backend' =&gt; 
              object(Zend_Cache_Backend_File)[10]
                ...
            protected '_options' =&gt; 
              array (size=9)
                ...
            protected '_specificOptions' =&gt; 
              array (size=0)
                ...
            private '_lastId' (Zend_Cache_Core) =&gt; string 'd11_DB_PDO_MYSQL_DDL_googleoptimizer_code_1' (length=43)
            protected '_extendedBackend' =&gt; boolean true
            protected '_backendCapabilities' =&gt; 
              array (size=6)
                ...
        protected '_isDdlCacheAllowed' =&gt; boolean true
        protected '_pdoType' =&gt; string 'mysql' (length=5)
        protected '_numericDataTypes' =&gt; 
          array (size=16)
            0 =&gt; int 0
            1 =&gt; int 1
            2 =&gt; int 2
            'INT' =&gt; int 0
            'INTEGER' =&gt; int 0
            'MEDIUMINT' =&gt; int 0
            'SMALLINT' =&gt; int 0
            'TINYINT' =&gt; int 0
            'BIGINT' =&gt; int 1
            'SERIAL' =&gt; int 1
            'DEC' =&gt; int 2
            'DECIMAL' =&gt; int 2
            'DOUBLE' =&gt; int 2
            'DOUBLE PRECISION' =&gt; int 2
            'FIXED' =&gt; int 2
            'FLOAT' =&gt; int 2
        protected '_defaultStmtClass' =&gt; string 'Zend_Db_Statement_Pdo' (length=21)
        protected '_config' =&gt; 
          array (size=12)
            'model' =&gt; string 'mysql4' (length=6)
            'initStatements' =&gt; string 'SET NAMES utf8' (length=14)
            'type' =&gt; string 'pdo_mysql' (length=9)
            'host' =&gt; string 'localhost' (length=9)
            'username' =&gt; string 'root' (length=4)
            'password' =&gt; 
              object(Mage_Core_Model_Config_Element)[34]
                ...
            'dbname' =&gt; string 'eyt' (length=3)
            'active' =&gt; string '1' (length=1)
            'charset' =&gt; null
            'persistent' =&gt; boolean false
            'options' =&gt; 
              array (size=3)
                ...
            'driver_options' =&gt; 
              array (size=0)
                ...
        protected '_fetchMode' =&gt; int 2
        protected '_profiler' =&gt; 
          object(Zend_Db_Profiler)[20]
            protected '_queryProfiles' =&gt; 
              array (size=0)
                ...
            protected '_enabled' =&gt; boolean false
            protected '_filterElapsedSecs' =&gt; null
            protected '_filterTypes' =&gt; null
        protected '_defaultProfilerClass' =&gt; string 'Zend_Db_Profiler' (length=16)
        protected '_connection' =&gt; 
          object(PDO)[17]
        protected '_caseFolding' =&gt; int 0
        protected '_autoQuoteIdentifiers' =&gt; boolean true
        protected '_allowSerialization' =&gt; boolean true
        protected '_autoReconnectOnUnserialize' =&gt; boolean false
    protected '_select' =&gt; 
      object(Varien_Db_Select)[324]
        protected '_bind' =&gt; 
          array (size=0)
            empty
        protected '_adapter' =&gt; 
          object(Varien_Db_Adapter_Pdo_Mysql)[90]
            protected '_transactionLevel' =&gt; int 0
            protected '_connectionFlagsSet' =&gt; boolean true
            protected '_ddlCache' =&gt; 
              array (size=1)
                ...
            protected '_bindParams' =&gt; 
              array (size=2)
                ...
            protected '_bindIncrement' =&gt; int 2
            protected '_debug' =&gt; boolean false
            protected '_logQueryTime' =&gt; float 0.05
            protected '_logAllQueries' =&gt; boolean false
            protected '_logCallStack' =&gt; boolean false
            protected '_debugFile' =&gt; string 'var/debug/sql.txt' (length=17)
            protected '_debugIoAdapter' =&gt; null
            protected '_debugTimer' =&gt; int 0
            protected '_cacheAdapter' =&gt; 
              object(Varien_Cache_Core)[13]
                ...
            protected '_isDdlCacheAllowed' =&gt; boolean true
            protected '_pdoType' =&gt; string 'mysql' (length=5)
            protected '_numericDataTypes' =&gt; 
              array (size=16)
                ...
            protected '_defaultStmtClass' =&gt; string 'Zend_Db_Statement_Pdo' (length=21)
            protected '_config' =&gt; 
              array (size=12)
                ...
            protected '_fetchMode' =&gt; int 2
            protected '_profiler' =&gt; 
              object(Zend_Db_Profiler)[20]
                ...
            protected '_defaultProfilerClass' =&gt; string 'Zend_Db_Profiler' (length=16)
            protected '_connection' =&gt; 
              object(PDO)[17]
                ...
            protected '_caseFolding' =&gt; int 0
            protected '_autoQuoteIdentifiers' =&gt; boolean true
            protected '_allowSerialization' =&gt; boolean true
            protected '_autoReconnectOnUnserialize' =&gt; boolean false
        protected '_parts' =&gt; 
          array (size=12)
            'straightjoin' =&gt; boolean false
            'distinct' =&gt; boolean false
            'columns' =&gt; 
              array (size=2)
                ...
            'union' =&gt; 
              array (size=0)
                ...
            'from' =&gt; 
              array (size=2)
                ...
            'where' =&gt; 
              array (size=0)
                ...
            'group' =&gt; 
              array (size=0)
                ...
            'having' =&gt; 
              array (size=0)
                ...
            'order' =&gt; 
              array (size=0)
                ...
            'limitcount' =&gt; null
            'limitoffset' =&gt; null
            'forupdate' =&gt; boolean false
        protected '_tableCols' =&gt; 
          array (size=0)
            empty
    protected '_cacheConf' =&gt; null
    protected '_idFieldName' =&gt; null
    protected '_bindParams' =&gt; 
      array (size=0)
        empty
    protected '_data' =&gt; null
    protected '_fetchStmt' =&gt; null
    protected '_items' =&gt; 
      array (size=0)
        empty
    protected '_itemObjectClass' =&gt; string 'Mage_Catalog_Model_Product' (length=26)
    protected '_orders' =&gt; 
      array (size=0)
        empty
    protected '_filters' =&gt; 
      array (size=0)
        empty
    protected '_isFiltersRendered' =&gt; boolean false
    protected '_curPage' =&gt; int 1
    protected '_pageSize' =&gt; boolean false
    protected '_totalRecords' =&gt; null
    protected '_isCollectionLoaded' =&gt; null
    protected '_cacheKey' =&gt; null
    protected '_cacheTags' =&gt; 
      array (size=0)
        empty
    protected '_cacheLifetime' =&gt; int 86400
    protected '_flags' =&gt; 
      array (size=0)
        empty
  </code></pre>