jcadima
4/22/2016 - 9:57 PM

Get Featured products custom

Get Featured products custom

<?php
/*
create /cendo/ma_cendo1/template/featuredcustom/featuredcustom.phtml
- create a category ID with featured, and note the ID
- check new products into this category 
*/

$counter = 1;
$products = Mage::getModel('catalog/category')->load(55); //put your category id here
       $productslist = $products->getProductCollection()->addAttributeToSelect('*');
       foreach($productslist as $product)
       {
	       if ($counter > 2 ) break;  // limit 2 products only
	       if ($counter > 1) { 
		       $position = 'text-right' ;
		   }
		   else {  
			   $position = 'text-left'  ;
		   }

	    echo "<div class='col-md-6   container-$position'>" ;
	    	echo "<div class='featimg $position'>"  . '<img src="' . $product->getImageUrl() . '"></div>' ;  
	    	
	    	echo "<div class='featname $position'>" .$product->getName() . '</div>' ;

	    	//echo 'Product Price : ' . $product->getPrice() . '<br/>';
	    	
	    	$shortdesc = substr($product->getDescription(), 0, 100 ) . ' ...' ;
	    	
	    	echo "<div class='$position'> " . $shortdesc . '</div>';
	    	
	    	echo "<div class='$position'>" .   '<a class="featbluebtn" href="' . $product->getProductUrl() . '">LEARN MORE</a></div>';	    	
	    	
	    echo '</div>';   
	  
        $counter++;
       }
       
       
THEN CALL THIS BLOCK IN A CMS PAGE:
  
{{block type="core/template" template="featuredcustom/featuredcustom.phtml"}}