addColumnCountLayoutDepend('empty', 6) ->addColumnCountLayoutDepend('one_column', 5) ->addColumnCountLayoutDepend('two_columns_left', 4) ->addColumnCountLayoutDepend('two_columns_right', 4) ->addColumnCountLayoutDepend('three_columns', 3); $this->addData(array('cache_lifetime' => 86400)); $this->addCacheTag(Mage_Catalog_Model_Product::CACHE_TAG); } public function getDefaultDirection() { return 'desc'; } public function getAvailableOrders() { return array('created_at' => 'Date'); } public function getProductCollection() { $this->getToolbarBlock()->enableExpanded(); $coll = $this->_getProductCollection(); return $coll; } protected function _beforeToHtml() { $toolbar = $this->getToolbarBlock(); // called prepare sortable parameters $collection = $this->_getProductCollection(); // use sortable parameters if ($orders = $this->getAvailableOrders()) { $toolbar->setAvailableOrders($orders); } if ($sort = $this->getSortBy()) { $toolbar->setDefaultOrder($sort); } if ($dir = $this->getDefaultDirection()) { $toolbar->setDefaultDirection($dir); } if ($modes = $this->getModes()) { $toolbar->setModes($modes); } // set collection to toolbar and apply sort $toolbar->setCollection($collection); //add pagination block $layout = Mage::getSingleton('core/layout'); $pager = $layout->createBlock('page/html_pager'); $toolbar->setChild('product_list_toolbar_pager', $pager); $this->setChild('toolbar', $toolbar); Mage::dispatchEvent('catalog_block_product_list_collection', array( 'collection' => $this->_getProductCollection() )); $this->_getProductCollection()->load(); return $this; } }