1

我正在尝试在主页上显示分层导航。我正在使用 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()

请帮忙。

4

1 回答 1

1

您是否尝试像这样添加完整的块:

 <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" />

没有渲染它不起作用

于 2015-04-03T08:16:06.990 回答