title: How to show featured product in home page magento?
body: <p>I want to show featured product in home page.For that i created an attribute 'Featured Product' in admin and set the featured product to 'yes'.
  Then i created a new file in <code>app/code/local/MyCompany/Catalog/Block/Product/Featured.php</code></p>
  
  <pre><code>&lt;?php
  class MyCompany_Catalog_Block_Product_Featured extends Mage_Catalog_Block_Product_Abstract
  {
      public function getFeaturedProducts() {
          $resource = Mage::getSingleton('core/resource');
          $read = $resource-&gt;getConnection('catalog_read');
          $productEntityIntTable = (string)Mage::getConfig()-&gt;getTablePrefix() . 'catalog_product_entity_int';
          $eavAttributeTable = $resource-&gt;getTableName('eav/attribute');
          $categoryProductTable = $resource-&gt;getTableName('catalog/category_product');
  
          $select = $read-&gt;select()
                          -&gt;distinct(true)
                          -&gt;from(array('cp'=&gt;$categoryProductTable), 'product_id')
                          -&gt;join(array('pei'=&gt;$productEntityIntTable), 'pei.entity_id=cp.product_id', array())
                          -&gt;joinNatural(array('ea'=&gt;$eavAttributeTable))
                          -&gt;where('pei.value=1')
                          -&gt;where('ea.attribute_code="featured"');
  
          $res = $read-&gt;fetchAll($select);
  
          return $res;
      }
  }
  ?&gt;
  </code></pre>
  
  <p>Then i created a new file in </p>
  
  <pre><code>app/code/local/MyCompany/Page/Block/Html.php
  
  &lt;?php
  
  class MyCompany_Mage_Page_Block_Html extends Mage_Page_Block_Html
  {
      public function getFeaturedProductHtml()
      {
          return $this-&gt;getBlockHtml('product_featured');
      }
  }
  </code></pre>
  
  <p>Then i added a new block in <code>app/etc/local.xml</code>  under config tag</p>
  
  <pre><code>&lt;blocks&gt;
      &lt;catalog&gt;
          &lt;rewrite&gt;
              &lt;product_featured&gt;MyCompany_Catalog_Block_Product_Featured&lt;/product_featured&gt;
          &lt;/rewrite&gt;
      &lt;/catalog&gt;
  &lt;/blocks&gt;
  </code></pre>
  
  <p>Then i added a new file in <code>app/design/frontend/default/mytheme/template/catalog/product/featured.phtml</code></p>
  
  <pre><code>&lt;?php $featured_products = $this-&gt;getFeaturedProducts(); ?&gt;
      &lt;?php shuffle($featured_products); ?&gt;
      &lt;div class="box recently" style="padding-left:15px; padding-right:15px;"&gt;
          &lt;h3&gt;&lt;?php echo $this-&gt;__('Featured Products') ?&gt;&lt;/h3&gt;
          &lt;div class="listing-type-grid  catalog-listing"&gt;
              &lt;?php $_collectionSize = count($featured_products) ?&gt;
              &lt;table cellspacing="0" class="recently-list" id="product-list-table"&gt;
                  &lt;?php 
                      $i=0; 
                      foreach ($featured_products as $_res): ?&gt;
                          &lt;?php $_product = Mage::getModel('catalog/product')-&gt;load($_res['product_id']); ?&gt;
                          &lt;?php if ($i++%3==0): ?&gt;&lt;tr&gt;&lt;?php endif ?&gt;
                          &lt;td&gt;
                              &lt;div&gt;
                                  &lt;a href="&lt;?php echo $_product-&gt;getProductUrl() ?&gt;" title="&lt;?php echo $this-&gt;htmlEscape($_product-&gt;getName()) ?&gt;"&gt;
                                      &lt;img class="product-image" src="&lt;?php echo $this-&gt;helper('catalog/image')-&gt;init($_product, 'small_image')-&gt;resize(135, 135); ?&gt;" width="135" height="135" alt="&lt;?php echo $this-&gt;htmlEscape($_product-&gt;getName()) ?&gt;" /&gt;
                                  &lt;/a&gt;
                              &lt;/div&gt;
                              &lt;p&gt;
                                  &lt;a class="product-name" href="&lt;?php echo $_product-&gt;getProductUrl() ?&gt;" title="&lt;?php echo $this-&gt;htmlEscape($_product-&gt;getName()) ?&gt;)"&gt;&lt;?php echo $this-&gt;htmlEscape($_product-&gt;getName()) ?&gt;&lt;/a&gt;
                              &lt;/p&gt;
                              &lt;?php echo $this-&gt;getReviewsSummaryHtml($_product, 'short') ?&gt;
                          &lt;/td&gt;
                          &lt;?php if ($i%3==0 &amp;&amp; $i!=$_collectionSize): ?&gt;&lt;/tr&gt;&lt;?php endif ?&gt;
                      &lt;?php endforeach ?&gt;
  
                      &lt;?php for($i;$i%3!=0;$i++): ?&gt;
                          &lt;td class="empty-product"&gt;&amp;nbsp;&lt;/td&gt;
                      &lt;?php endfor ?&gt;
                      &lt;?php if ($i%3==0): ?&gt;&amp;nbsp;&lt;?php endif ?&gt;
              &lt;/table&gt;
              &lt;script type="text/javascript"&gt;decorateTable('product-list-table')&lt;/script&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p>Then i call this page in home cms page using this code</p>
  
  <pre><code>{{block type="catalog/product_featured" name="product_featured" as="product_featured" template="catalog/product/featured.phtml}}
  </code></pre>
  
  <p>But after clearing the cache also, product is not showing in home page only shows the <code>Featured Products</code> heading.I don't know where i am getting mistake.
  If anyone knows this, then please help me out.
  Thanks!</p>