我正在尝试在主页上显示分层导航。我正在使用 magento 1.9.0。并插入以下xmlLayout Update XML
<reference name="left">
<block type="catalog/layer_view" name="catalog.leftnav" after="currency" template="catalog/layer/view.phtml"/>
</reference>
然后在app\code\core\Mage\Catalog\Model\layer.php
修改函数getCurrentCategory()
中如下获取主页上的根目录:
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;
}
但是发生了以下错误:
致命错误:在第 174 行的 app\code\core\Mage\Catalog\Model\Layer.php 中的非对象上调用成员函数 load()
请帮忙。