1

ホームページに階層化されたナビゲーションを表示しようとしています。私はmagento 1.9.0を使用しています。次のxmlを挿入しましたLayout 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 に答える