Now go to Catalog-> Attributes -> Manage Attribute Sets . Click on your Attribute set (e.g : - I choose Default attribute set) then add the Special attribute from Unassigned Attributes to Groups by drag and drop. Now go to any products which have same attribute set in which the Special Attribute is assign, There you can see that Special Product Option has came with yes/no drop down. Now make some product Yes as Special product.
Now go to frontend and write the below code where you want to fetch the Special Product.
$storeId = Mage::app()->getStore()->getId(); $resource = Mage::getSingleton('core/resource'); $read = $resource->getConnection('catalog_read'); $categoryProductTable = $resource->getTableName('catalog/category_product'); $productEntityIntTable = (string)Mage::getConfig()->getTablePrefix() . 'catalog_product_entity_int'; $eavAttributeTable = $resource->getTableName('eav/attribute'); // Query database for special product $select = $read->select() ->distinct() ->from(array('cp'=>$categoryProductTable),'cp.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="special"');// Write your attribute code instead of Special $rows = $read->fetchAll($select); // Save all product Id which have the Special Product Yes foreach($rows as $row) { $product[] =$row['product_id']; }
Inside the $product variable you have all product Id which are Special Product . Now write the Below code to get Details of the Each product
- $val)
{
$productobject = Mage::getModel('catalog/product');
$productmodel = $productobject->load($val);
echo "
- ";
echo "".$productmodel->getName()."
";
echo "";
echo "".$productmodel->getDescription()."
";
echo "".$productmodel->getFinalPrice()."
";
?>
";
?>
You can see all the Special Product has come to your frontend. By this way you can make Feature Product
Hope it Helps.. Thanks....
No comments:
Post a Comment