Display Featured Product Radomly on Magento HomePage

Create new file homepage.phtml and copy content from list.phtml to homepage.phtml, log in to your magento admin go to cms pages click home page
paste step1 to contect area. click save.

strp 1.

{{block type=”catalog/product_list”  category_id=”93″ template=”catalog/product/homepage.phtml”}}

now open  hopepage.phtml use the code below to randomly display 4 product at once

step 2.
<?php
$_productCollection=$this->getLoadedProductCollection();
$_helper = $this->helper(‘catalog/output’);
    if ($_productCollection->count()):
    $_productCollection = $_productCollection->getItems();
    shuffle($_productCollection);
    $i = 0;
             foreach ($_productCollection as $_product):
        if ($i < 4):
                             // Product Data With CSS
        endif;
    $i++;
     endforeach;
    endif;

?>

Leave a Comment

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

*