Monday, 21 October 2013

change list to any perticular category


----------for a perticular Category--------------------


<?php
//echo $this->getProductCollection()->getSelectSql();
$catagory_model = Mage::getModel('catalog/category')->load('59'); //where $category_id is the id of the category

$_products = Mage::getResourceModel('catalog/product_collection');

$_products->addCategoryFilter($catagory_model); //category filter

$_products->addAttributeToFilter('status',1); //only enabled product

$_products->addAttributeToSelect(array('name','url','small_image','special_price')); //add product attribute to be fetched

//$collection->getSelect()->order('rand()'); //uncomment to get products in random order     
$_products->addAttributeToSort('special_from_date', 'asc');
$_products->addStoreFilter();

//echo count($_products);
?>
<?php if (!empty($_products)): ?>



------------------For all product or another conditionm----------------------


<?php if (($_products = $this->getProductCollection()) && $_products->getSize()): ?>

No comments:

Post a Comment