Recent Blogs

  • Why A Travel Company Needs An Attractive Website?

    A website considered a great source of a marketing platform for a travel company. It is a place where you can share your availability and regularity all the time without unusual hindrances. A website should be responsive, user-friendly, and easy to operate. A travel company promotes itself through the best website to put trustworthy content. It may promote visitors and it would be a great platform to place tour packages.

    Why travel agencies needs a attractive website

    12-06-2020

How to add featured product in Magento home page

The homepage of your website plays a vital role in your business. Online Shoppers will understand your homepage first before they choose to shop, so your business is to create the homepage engaging to the customer.
If not, they will leave your site instantly. One of the best ways to attract users by inserting your primary or trending products on the home page. So there is a huge chance of getting more buyers.

Lets learn how to add products in Magento of your websites homepage

Create a Featured Attribute in Magento Backend first Create an attribute featured with yes/no property from Catalog Input Type for Store Owner drop-down, then include it in attribute set and assign one product as Featured “yes” from Catalog->Manage Products.

Create a Custom Module

Create custom module and block file “app/code/local/FeaturedProduct/Catalog/Block/Product/Featured.php” with following code in it.

  
class FeaturedProduct_Catalog_Block_Product_Featured extends Mage_Catalog_Block_Product_List
{
    protected $_productCollection;
    public function fetchProducts()
    {
       $this->productCollection =Mage::getModel('catalog/product')->getCollection()
        ->addAttributeToSelect('*')
        ->addFieldToFilter('featured_products', array('eq' => '1'));
      return $this->productCollection;
    }
}

Create a configuration file in app/code/local/FeaturedProduct/Catalog/etc/config.xml
You have to specify a configuration file to tell magento about which XML is going to declare the block need to display featured products in homepage and which is located in app/code/local/FeaturedProduct/Catalog/etc/config.xml as:

  



        
            1.0.0                        
        


        
            
                FeaturedProduct_Catalog_Block
            
        


        
            
                
                    featuredproduct.xml
                
            
        


Create featuredproducts.xml in location app/design/frontend/mytheme/default/layout/featuredproduct.xml as follows:

 


    
        
            
                
                    4
                
            
        
    

Finally, create a view file to display featured products in a Grid layout as :
Create view file "app/design/frontend/mytheme/default/template/catalog/product/featured.phtml" with following code in it :

  
fetchProducts();
    $_helper = $this->helper('catalog/output');
?>
count()): ?>

__('There are no products in the featured product list!!') ?>

count() ?> getColumnCount(); ?>
 

That’s it.
Prefer to choose Installer Script for creating featured attribute mentioned in the beginning.
I hope you understood on How to add featured product in home page in Magento.
Try it

Leave a Reply

Your email address will not be published. Required fields are marked *