Magento Themes and Magento Extensions

Setting Up Featured Products In Magento


ecommerce shops feel the urge to showcase their special products or featured products either on their shop’s home page or category listing pages depending upon the requirement. Various ecommerce scripts have already developed this feature and you will see a dropdown or a radio button to mark a product as featured. Unfortunately, Magento doesn’t provide this option by default. There are numerous Magento extensions available which will do the job including our Featured product slider which creates the custom attribute called “featured” and shows on product catalog page (admin) but if you are looking for a extension free solution then read on.

Creating new custom attribute called “Featured”

First of all you will have to create a custom attribute called “featured”. Go to Catalog => Manage Attribute => Add New and enter “featured” as attribute code. Choose Scope as “Global” or choose as per your website. Under Catalog Input Type choose “Yes/No” (you can not change this once an attribute is created).

[* Click on Image to see large preview]

On the right hand side under the “Attribute Information” just select “Manage Label / Options” and give it a name like “Featured” under admin input box. If you want to enable this for a particular store add the label in that column.

Finally, click Save button. Your new Featured product attribute is created and ready but before you see that in Product Catalog creation page you have to assign this newly created attribute to it’s proper place. Go to Catalog => Manage Attribute => Manage Attribute Sets Now you can see featured attribute under Unassigned Attributes, just drag it and place it in General section under visibility and click on Save Attribute Set button.

Now goto Catalog => Manage Products and Edit the product which you wish to mark as Featured. In General Section you will find an attribute called “Featured” just under visibility. Select yes from the drop down and click save.

If you are using our Featured Product slider extension then it will automatically fetch all the products marked as featured and showcase on your home page or wherever but if you want to show the featured products manually then the following code might be of your interest.

Create Featured Product Template

Use your favorite ftp editor and go to app => design => frontend
=> default => {Your Theme} => template
and create a new directory called custom and create a new file called featured_products.phtml inside the custom directory so it’s looks like app => design => frontend
=> default => {Your Theme} => template => custom => featured_products.phtml
Now add the following code inside the file

<div id="home-featured">
        <h3><?php echo $this->__('Featured products') ?></h3>

		// some helpers
		$_helper = $this->helper('catalog/output');
		$storeId = Mage::app()->getStore()->getId();
		$catalog = $this->getLayout()->createBlock('catalog/product_list')

		// get all products that are marked as featured
		$collection = Mage::getModel('catalog/product')->getCollection();
			array('attribute' =>
'eq' => true),

		// if no products are currently featured, display some text
		if (!$collection->count()) :

	<p><?php echo $this->__('There are no featured
products at the moment.') ?></p>

	<?php else : ?>


		$_collectionSize = $collection->count();
		$_columnCount = 4;
		$i = 0;

		foreach ($collection as $_product) :
			$_product = Mage::getModel('catalog/product')->setStoreId


	    <?php if ($i++%$_columnCount==0): ?>
	    <?php endif ?>
	            <a href="<?php echo $_product->getProductUrl() ?>
" title="<?php echo $this->stripTags($this->getImageLabel($_product,
 null, true) ?>"><img src="<?php echo $this->
->init($_product, 'small_image')->resize(135); ?>" width="135" height="135"
 alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'),
 null, true) ?>" /></a>
	            <h2><a href="<?php echo $_product->getProductUrl()
?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>"><?php
 echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></a&gt
	            <?php if($_product->getRatingSummary()): ?>
	            <?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
	            <?php endif; ?>
	            <?php echo $this->getPriceHtml($_product, true) ?>
	                <?php if($_product->isSaleable()): ?>
	                    <button type="button" title="<?php echo $this->
__('Add to Cart') ?>" onclick="setLocation
('<?php echo $catalog->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; ?>
	                    <?php if ($this->helper('wishlist')->isAllow()) : ?>
	                        <li><a href="<?php echo $this->helper('wishlist')
->getAddUrl($_product) ?>"><?php echo $this->
__('Add to Wishlist') ?></a></li>
	                    <?php endif; ?>
	                    <?php if($_compareUrl=$catalog->getAddToCompareUrl($_product)): ?>
	                        <li><span>|</span> <a href="<
?php echo
 $_compareUrl ?>"><?php echo $this->__('Add to Compare') ?></a></li>
	                    <?php endif; ?>
	    <?php if ($i%$_columnCount==0 || $i==$_collectionSize): ?>
	    <?php endif ?>

		<?php endforeach ?>
        <script type="text/javascript">decorateGeneric($$('ul.products-grid'),
	<?php endif ?>

In the above code you can change the design and div’s to match with your existing design.

Adding Featured Product Template On Magento Home Page

Finally, we have few featured products in system and we also have a featured product template. All we have to do now is add this new block to your stores homepage. Go to CMS => Pages and edit the Homepage. In the left menu go to Design and enter the following into Layout Update XML:

<reference name="content">
<block type="core/template" name="home-featured" template="custom/featured_products.phtml"/>
You are all set! Please leave me a comment and let me know if you face  any difficulty
in implementing Featured Products in your Magento store.  Subscribe our RSS to receive
 latest Magento updates.

Leave a Reply

You must be logged in to post a comment.