<?php $_productCollection = Mage::getModel('catalog/product')->getCollection(); $_productCollection->addAttributeToFilter('feature','1'); //custom attribute is yes/no(1,0) $_productCollection->addAttributeToFilter('status', 1); //enabled $_productCollection->addAttributeToFilter('visibility', 4); //catalog, search ?> <?php foreach ($_productCollection as $_product) { $model = Mage::getModel('catalog/product'); $product_id = $_product->getId(); $_product = $model->load($product_id); //echo $_product->getPrice().""; //echo $_product->getName().""; $_image=Mage::getModel('catalog/product')->load($product_id); //echo Mage::helper('catalog/image')->init($_image, 'image').""; ?> <div class="feature-product"> <div class="feature-product-price"><?php echo $_product->getPrice(); ?></div> <div class="feature-product-name"><?php echo $_product->getName(); ?></div> <div class="feature-product-image"><a href="<?php echo $_product->getProductUrl() ?>"><img src="<?php echo Mage::helper('catalog/image')->init($_image, 'image')->resize(200,200); ?>"></a></div> </div> <?php } ?>
===================== OR =====================
Add Featured Product in your home page
Add this code in your phtml page but you need some implementation…..
$featured_products=Mage::getModel('catalog/product') ->getCollection() ->addAttributeToFilter('status', 1) ->addAttributeToFilter('visibility', 4) ->addAttributeToFilter('featured', 1); foreach($featured_products as $featured_product) { $_product=Mage::getModel('catalog/product')->load($featured_product->getId()); echo $_product->getName(); }
0 Comments