I have followed this guide, and have had new products display for some time now, but the filter on the left hand side never displayed: http://www.dnawebagency.com/displaying-new-products-in-magento-with-pagination/
This code is as follows under /app/code/local/Mage/Catalog/Block/Product/New.php
<?php
class Mage_Catalog_Block_Product_New extends Mage_Catalog_Block_Product_List
{
function get_prod_count()
{
//unset any saved limits
Mage::getSingleton('catalog/session')->unsLimitPage();
return (isset($_REQUEST['limit'])) ? intval($_REQUEST['limit']) : 12;
}// get_prod_count
function get_cur_page()
{
return (isset($_REQUEST['p'])) ? intval($_REQUEST['p']) : 1;
}// get_cur_page
/**
* Retrieve loaded category collection
*
* @return Mage_Eav_Model_Entity_Collection_Abstract
**/
protected function _getProductCollection()
{
$todayDate = Mage::app()->getLocale()->date()->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
//$collection = Mage::getResourceModel('catalog/product_collection');
$collection = Mage::getModel('catalog/product')->getCollection();
$collection->setVisibility(Mage::getSingleton('catalog/product_visibility')->getVisibleInCatalogIds());
$collection = $this->_addProductAttributesAndPrices($collection)
->addStoreFilter()
->addAttributeToFilter('news_from_date', array('date' => true, 'to' => $todayDate))
->addAttributeToFilter('news_to_date', array('or'=> array(
0 => array('date' => true, 'from' => $todayDate),
1 => array('is' => new Zend_Db_Expr('null')))
), 'left')
->addAttributeToSort('news_from_date', 'desc')
->setPageSize($this->get_prod_count())
->setCurPage($this->get_cur_page());
$this->setProductCollection($collection);
return $collection;
}// _getProductCollection
}// Mage_Catalog_Block_Product_New
?>
Now I got the filter on the page using the following XML on the page template
<!-- add layered navigation to left column -->
<reference name="left">
<block type="catalog/layer_view" name="catalog.leftnav" before="-" template="catalog/layer/view.phtml" />
</reference>
Now the filter on the left hand side displays, but it shows all category counts, and when clicking any of the filters, it does not narrow the search down on the current new stock.
I have been scratching my head and searching all over the net to try and get this to work.
Anyone have any ideas?
The full xml on the page is as follows
<action method="addFilter">
</action>
<reference name="content">
<block type="catalog/product_new" name="product_list" after="product_filter" template="catalog/product/list.phtml">
<action method="setCategoryId"><category_id>3</category_id></action>
<block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
<block type="page/html_pager" name="product_list_toolbar_pager"/>
</block>
<action method="addColumnCountLayoutDepend"><layout>empty</layout>
<count>6</count>
</action>
<action method="addColumnCountLayoutDepend">
<layout>one_column</layout>
<count>5</count>
</action>
<action method="addColumnCountLayoutDepend">
<layout>two_columns_left</layout>
<count>3</count>
</action>
<action method="addColumnCountLayoutDepend">
<layout>two_columns_right</layout>
<count>4</count>
</action>
<action method="addColumnCountLayoutDepend">
<layout>three_columns</layout>
<count>3</count>
</action>
<action method="setToolbarBlockName">
<name>product_list_toolbar</name>
</action>
</block>
</reference>
<!-- add layered navigation to left column -->
<reference name="left">
<block type="catalog/layer_view" name="catalog.leftnav" before="-" template="catalog/layer/view.phtml" />
</reference>