0
votes

I need to display new items in magento specific category.

I have found:

{{block type="catalog/product_new" name="home.catalog.product.new" alias="product_new" template="catalog/product/new.phtml"}}

however it shows store wide items, and also found:

{{block type="catalog/product_list" category_id="Category-ID” template="catalog/product/list.phtml"}}

But it show all products, not only new ones.

How can I fix this?

1

1 Answers

0
votes

If you use(notice that I changed filename to listnew.phtml):

{{block type="catalog/product_list" category_id="Category-ID" template="catalog/product/listnew.phtml"}}

Clone in root/app/design/frontend/<package>/<theme>/template/catalog/product/ list.phtml to listnew.phtml and replace in it:

$_productCollection=$this->getLoadedProductCollection();

with

$_categoryId = $this->getCategoryId();

$_productCollection = Mage::getModel('catalog/category')->load($_categoryId)
    ->getProductCollection()
    ->addAttributeToSelect('*')
    ->addAttributeToFilter('status', 1)
    ->addAttributeToFilter('visibility', 4)
    ->addAttributeToFilter(
                array(
                    array('attribute' => 'news_from_date', 'is'=>new Zend_Db_Expr('not null')),
                    array('attribute' => 'news_to_date', 'is'=>new Zend_Db_Expr('not null'))
                    )
                )
    ->setOrder('news_from_date', 'ASC');