I am trying to show a layered navigation on homepage. I m using magento 1.9.0. and inserted following xml in Layout Update XML
<reference name="left">
<block type="catalog/layer_view" name="catalog.leftnav" after="currency" template="catalog/layer/view.phtml"/>
</reference>
Then in app\code\core\Mage\Catalog\Model\layer.php
modified function getCurrentCategory()
as follows to get root category on home-page:
public function getCurrentCategory()
{
$category = $this->getData(’current_category’);
if (is_null($category)) {
if ($category = Mage::registry(’current_category’)) {
$this->setData(’current_category’, $category);
}
else {
$category = false;
$this->setData(’current_category’, $category);
}
}
// added to make this work for front page:
if(is_null($category) || $category == false) {
$home_category = Mage::getModel(’catalog/category’)->load(4); //number must correspond to ‘all products page’ category
$this->setData(’current_category’, $home_category);
$category = $this->getData(’current_category’);
return $category;
}
//end addition
return $category;
}
But Following error has occurred:
Fatal error: Call to a member function load() on a non-object in app\code\core\Mage\Catalog\Model\Layer.php on line 174
Please help.
Did you try to add the complete block like this:
<block type="catalog/layer_view" name="catalog.layer.filter.view" template="catalog/layer/view.phtml"/>
<block type="core/text_list" name="catalog.left.state.renderers" as="state_renderers" />
Without the render it doesn't function