カテゴリ固有のレイヤードナビゲーションの変更(属性フィルターの無効化)[閉じた

magento.stackexchange https://magento.stackexchange.com/questions/11567

  •  16-10-2019
  •  | 
  •  

質問

特定のカテゴリのレイヤードナビゲーションで特定の属性フィルターを無効にしようとしています。私が無効にしたい属性フィルターは、この場合のメーカーです。

問題のカテゴリの「カスタムデザインレイアウト」で以下を試しています。-

<block type="catalog/layer_view" name="catalog.leftnav" after="currency" template="catalog/layer/view.phtml">
    <action method="unsetChild"><alias>manufacturer_filter</alias></action>
</block>

これは半分動作しており、メーカーフィルターを階層化されたナビゲーションに隠しますが、これの下に他のすべてを隠します catalog.leftnav.

それが起こらないようにするために、上記の変更がどのように変更される必要があるかは考えられますか?

私が意味することを説明するために、スクリーンショットがあります。

XMLアップデートの前

enter image description here

XMLアップデート後

enter image description here

役に立ちましたか?

解決

あなたが書き直すと、これを達成できます Mage_Catalog_Model_Layer::getFilterableAttributes 方法。
特定のカテゴリの場合、新しいフィルターを追加できます。

このようなもの(テストされていません)

public function getFilterableAttributes()
{
    $setIds = $this->_getSetIds();
    if (!$setIds) {
        return array();
    }
    $collection = Mage::getResourceModel('catalog/product_attribute_collection');
    $collection
        ->setItemObjectClass('catalog/resource_eav_attribute')
        ->setAttributeSetFilter($setIds)
        ->addStoreLabel(Mage::app()->getStore()->getId())
        ->setOrder('position', 'ASC');
    if ($this->getCurrentCategory()->getId() == 7) {
         //if in that specific category...You can even make this a category setting or a config setting so you won't hard code it.  
         $collection->addFieldToFilter('attribute_code', array('neq'=>'manufacturer'));
    }

    $collection = $this->_prepareAttributeCollection($collection);
    $collection->load();

    return $collection;
}
ライセンス: CC-BY-SA帰属
所属していません magento.stackexchange
scroll top