I want to display products as featured in homepage and also like to display products as latestproducts in homepage.i'm a magento beginner, please help me how to do this?It is possible to display products as featured using admin panel itself???

Thanks in advance...!


1 Answer 1


Update 1: From comment: How to update catalog input type for store owner ?

update catalog input type for store owner

The following are the steps to add featured products on homepage.

STEP: 1. To make featured product attribute.

  • Login to Magento admin area.
  • Now add attribute from tab

Catalog–>Attribute –> Manage Attribute–>Add New Attribute.

Attribute Properties to be set

  • Attribute Identifier: featured

  • Scope: Store View

  • Catalog Input Type For Store Owner: Yes/No

  • Unique Value (not shared with other product): No

  • Values Required: No

  • Input Validation for Store Owner: None

  • Apply To: All Product Types

Front End Properties to be set

  • Use In quick Search: No

  • Use In Advance Search: Yes

  • Comparable on Front-end: No

  • Use In Layered navigation (Can be used only with catalog input type ‘Dropdown‘): No

  • Visible on Catalog Pages On Front-end: Yes

Manage label/options to be set

  • Default: Featured Product

  • English: Featured Product

Now add featured product attribute in attribute set:

Goto Catalog –>Attributes–>Manage Attribute sets.

Our featured product attribute will be displayed in “Unassigned attribute” in right end side of the screen. Now drag and drop our “featured product” attribute in ‘General’ tab of “Groups” displayed in left end side of screen. Now click on “save attribute set” button. See the screen shot for reference.


STEP: 2. Create featured product block file.

Go to Local directory app/code/local/ and create directory. Create directory level “Featured Product/Catalog/Block/Product/Featured.php”


class FeaturedProduct_Catalog_Block_Product_Featured extends Mage_Catalog_Block_Product_Abstract {
    public function getFeaturedProduct() {
//database connection object
        $storeId               = Mage::app()->getStore()->getId();
        $resource              = Mage::getSingleton( 'core/resource' );
        $read                  = $resource->getConnection( 'catalog_read' );
        $categoryProductTable  = $resource->getTableName( 'catalog/category_product' );
        $productEntityIntTable = (string) Mage::getConfig()->getTablePrefix() . 'catalog_product_entity_int';
        $eavAttributeTable     = $resource->getTableName( 'eav/attribute' );
// Query for featured product
        $select = $read->select()
                       ->from( array( 'cp' => $categoryProductTable ) )
                       ->join( array( 'pei' => $productEntityIntTable ), 'pei.entity_id=cp.product_id', array() )
                       ->joinNatural( array( 'ea' => $eavAttributeTable ) )
                       ->where( 'pei.value=1' )
                       ->where( 'ea.attribute_code="featured"' );
        $row    = $read->fetchRow( $select );

        return Mage::getModel( 'catalog/product' )->setStoreId( $storeId )->load( $row['product_id'] );

STEP: 3. Create template file for featured product.

Go to directory “app/design/frontend/my_theme/template/catalog/product/” and make featured.phtml file. Replace my_theme with your current theme name. Copy and paste this code in featured.phtml file.

$totalPerPage       = ( $this->show_total ) ? $this->show_total : 6;
$visibility         = array(
$storeId            = Mage::app()->getStore()->getId();
$_productCollection = Mage::getResourceModel( 'reports/product_collection' )
                          ->addAttributeToSelect( '*' )
                          ->setStoreId( $storeId )
                          ->addStoreFilter( $storeId )
                          ->addAttributeToFilter( 'visibility', $visibility )
                          ->addAttributeToFilter( 'featured', true )
                          ->setOrder( 'created_at', 'desc' )
                          ->addAttributeToSelect( 'status' )
                          ->setPageSize( $totalPerPage );

Mage::getSingleton( 'catalog/product_status' )->addVisibleFilterToCollection( $_productCollection );
Mage::getSingleton( 'cataloginventory/stock' )->addInStockFilterToCollection( $_productCollection );
Mage::getSingleton( 'catalog/product_visibility' )->addVisibleInSearchFilterToCollection( $_productCollection );

<h1>Featured products</h1><br><br>
    <?php $_collectionSize = $_productCollection->count() ?>
    <table cellspacing="0" class="generic-product-grid" id="product-list-table" style="margin-top:-50px; width:960px;">
        <?php $i = 0;
        foreach ( $_productCollection as $_product ): ?><?php if ( $i ++ % 3 == 0 ): ?>
            <tr style="margin-top:20px;"><?php endif ?>
            <td><p class="product-image" style="width:330px; margin-top:20px;">
                    <a href="<?php echo $_product->getProductUrl() ?>"
                       title="<?php echo $this->htmlEscape( $this->getImageLabel( $_product, 'small_image' ) ) ?>">
                        <img style="height:190px; width:300px;"
                             src="<?php echo $this->helper( 'catalog/image' )->init( $_product, 'small_image' )->resize( 170, 170 ); ?>"
                             alt="<?php echo $this->htmlEscape( $this->getImageLabel( $_product, 'small_image' ) ) ?>"
                             title="<?php echo $this->htmlEscape( $this->getImageLabel( $_product, 'small_image' ) ) ?>"/></a>
                <?php /*?><h5><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>"><?php echo $this->htmlEscape($_product->getName()) ?></a></h5><?php */ ?>
                    <?php echo $_product->getShortDescription() ?></div>
                    <?php if ( $_product->getSpecialPrice() > 0 ): ?>
                            class="old"><?php echo $this->helper( 'checkout' )->formatPrice( $_product->getPrice() ) ?></span>&nbsp;
                            class="new"><?php echo $this->helper( 'checkout' )->formatPrice( $_product->getSpecialPrice() ) ?></span><?php else: ?>
                            class="new"><?php echo $this->helper( 'checkout' )->formatPrice( $_product->getPrice() ) ?></span>
                    <?php endif; ?><?php if ( $_product->isSaleable() ): ?>
                    <button type="button" title="<?php echo $this->__( 'Add to Cart' ) ?>" class="button btn-cart"
                            onclick="setLocation('<?php echo $this->getAddToCartUrl( $_product ) ?>')">
                        <span><span><?php echo $this->__( 'Add to Cart' ) ?></span></span></button><?php else: ?>
                        <p><span><?php echo $this->__( 'Out of stock' ) ?></span></p>
                    <?php endif; ?></div>
                <div class="clear"></div>
            <?php if ( $i % 3 == 0 && $i != $_collectionSize ): ?></tr><?php endif ?><?php endforeach ?>
        <?php for ( $i

        $i % 3 != 0;
        $i ++ ): ?>
        <td class="empty-product">&nbsp;</td>
        <?php endfor ?><?php if ( $i % 3 == 0 ): ?></tr><?php endif ?></table>
    <script type="text/javascript">decorateTable('product-list-table')</script>

STEP: 4. Add new block to the app/etc/local.xml

Add the following code after the global tag ends:


STEP: 5. Add featured product block in home page.

Now we need place the featured product box to the frontend homepage. To do this:

Go to CMS > Manage Pages > Homepage

enter image description here

Copy and paste this featured product block on home page

{{block type="core/template" name="product_featured" as="product_featured" template="catalog/product/featured.phtml"}}

You should be able to see featured products on your homepage.

  • how to change (Catalog Input Type for Store Owner) tab it displays as text
    – abdul
    Jan 3, 2017 at 10:56
  • I have updated answer and added screenshot indicating how to change catalog input type for store owner. Jan 3, 2017 at 11:05
  • Fatal error: Call to a member function getBackend() on boolean in C:\xampp\htdocs\magento\app\code\core\Mage\Eav\Model\Entity\Abstract.php on line 816 Mar 4, 2017 at 5:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.