How to create featured products on Magento frontpage?

What is featured product?

Featured product is an item of sale provided with a specific attribute from the administrative UI. The products positioned as featured usually fit into such groups as ‘best value’, ‘on sale’, ‘speciality’, etc. 

Why do you need a featured product?

Placing a product on a store’s homepage makes it even more fascinating for buyers. It’s a proven way to attract customer’s attention and bring it to this particular product. The possibility boosts sales and traffic exponentially.  

How to create featured product on the frontpage?

The featured product can’t be created through the usage of standard tools, therefore you’ll need a customized code for the purpose. Besides, you can apply the Easy Content Blocks extension for displaying desired information blocks on any page of your website.  

Step 1: Create a new product attribute

  • Go to Catalog>Attributes>Manage Attributes>Add New Attribute and set the next properties for the attribute:

attribute-properties-magento

  • Set the following properties for the frontend:

frontend-properties-magento

  • Manage Label/Options:

manage-labels-options-magento

  • Once the newly-created attribute is saved, enter the Catalog>Attributes>Manage Attributes Sets
    and add it to the Default attribute set:

     

manage-attribute-sets-magento

  • Being displayed in ‘Unassigned attributes’ the featured product attribute should be dragged and dropped in Groups>General tab and click the ‘Save Attribute Set’ button:unassigned-features-to-stores-magento

Step 2: Create a new block class

The new block is required for the featured product instantiation. For this reason, you need to make a new file and directories:

Go to app/code/local/MyCompany/Catalog/Block/Product/Featured.php 

<?php
class MyCompany_Catalog_Block_Product_Featured extends Mage_Catalog_Block_Product_Abstract
{
public function getFeaturedProducts() {
$resource = Mage::getSingleton('core/resource');
$read = $resource->getConnection('catalog_read');
$productEntityIntTable = (string)Mage::getConfig()->getTablePrefix() . 'catalog_product_entity_int';
$eavAttributeTable = $resource->getTableName('eav/attribute');
$categoryProductTable = $resource->getTableName('catalog/category_product');

$select = $read->select()
->distinct(true)
->from(array('cp'=>$categoryProductTable), 'product_id')
->join(array('pei'=>$productEntityIntTable), 'pei.entity_id=cp.product_id', array())
->joinNatural(array('ea'=>$eavAttributeTable))
->where('pei.value=1')
->where('ea.attribute_code="featured"');

$res = $read->fetchAll($select);

return $res;
}
}
?>

Step 3: Make new blocks for the app/code/local/MyCompany/Catalog/etc/config.xml

The config global tag should be expanded with the following code:

<?xml version="1.0"?>
<config>
<modules>
<MyCompany_Catalog>
<version>1.0.0</version>
</MyCompany_Catalog>
</modules>
<global>
<blocks>
<amcompany>
<class>MyCompany_Catalog_Block</class>
</amcompany>
<rewrite>
<catalog>
<product_featured>MyCompany_Catalog_Block_Product_Featured</product_featured>
</catalog>
</rewrite>
</blocks>
</global>
</config>

Step 4: Add the code to the file app/design/frontend/base/default/template/catalog/product/featured.phtml

code-magento

 Step 5: Check the blocks have been permitted

  • Go to the Admin Panel>System>Permissions

check-blocks-permission-magento

blocks-allowed-magento

  • Navigate to the Block and click the Add New Block option to make the next settings:

block-name-is-allowed-magento

Step 6: The Magento featured products block should be added to the frontpage

Now the featured product box should be placed to the frontpage.
Enter CMS - Manage Pages and choose homepage( or another page if you don’t want the featured product to be placed on the homepage).
Then place the code in the Content area:

last-code-magento

So, that's all you should do for configuring the featured product.

To add Magento product price slider and place it on the home page, try this Price Slider & Filters extension. Thanks to AJAX technology, your shoppers will convert their intents to purchase into orders faster as navigation and filtering will be practically seamless.

How can we help you?

Didn’t you find the answer to your question? We are always happy to help you out.

© 2009-2024 Amasty. All Rights Reserved.