/** * Retrieve loaded category collection * * @return Mage_Eav_Model_Entity_Collection_Abstract */ protected function _getProductCollection() { if (is_null($this->_productCollection)) { $layer = $this->getLayer(); $origCategory = null; if ($this->getCategoryId()) { $category = Mage::getModel('catalog/category')->load($this->getCategoryId()); if ($category->getId()) { $origCategory = $layer->getCurrentCategory(); $layer->setCurrentCategory($category); } } $this->_productCollection = $layer->getProductCollection(); $this->prepareSortableFieldsByCategory($layer->getCurrentCategory()); if ($sort = $this->getSortBy()) { $this->_productCollection->setOrder($sort); } if ($origCategory) { $layer->setCurrentCategory($origCategory); } } return $this->_productCollection; }