0

階層化されたナビゲーションで、特定の属性を選択すると左側の選択パネルから消えてしまうので、複数選択できるようにしたいです。どのコレクションから来るのかがわかれば助かります。

-前もって感謝します。

public function apply(Zend_Controller_Request_Abstract $request, $filterBlock) {
    $filter = $request->getParam($this->_requestVar);
    if (is_array($filter)) {
        $text = array();
        foreach ($filter as $f)
            array_push ($text, $this->_getOptionText($f));
            if ($filter && $text) {
            $this->_getResource()->applyFilterToCollection($this, $filter);
            $this->getLayer()->getState()->addFilter($this->_createItem($text, $filter));
            $this->_items = array();
        }
        return $this;
    }
    $text = $this->_getOptionText($filter);
    if ($filter && $text) {
        $this->_getResource()->applyFilterToCollection($this, $filter);
        $this->getLayer()->getState()->addFilter($this->_createItem($text, $filter));
        $this->_items = array();
    }
    return $this;
}


public function applyFilterToCollection($filter, $value)
{
    $collection = $filter->getLayer()->getProductCollection();
    $attribute  = $filter->getAttributeModel();
    $connection = $this->_getReadAdapter();
    $tableAlias = $attribute->getAttributeCode() . '_idx';
     if (!is_array($value)) {
        $conditions = array(
        "{$tableAlias}.entity_id = e.entity_id",
        $connection->quoteInto("{$tableAlias}.attribute_id = ?", $attribute->getAttributeId()),
        $connection->quoteInto("{$tableAlias}.store_id = ?", $collection->getStoreId()),
        $connection->quoteInto("{$tableAlias}.value = ?", $value)
    );
     }else{

         $conditions = array(
        "{$tableAlias}.entity_id = e.entity_id",
        $connection->quoteInto("{$tableAlias}.attribute_id = ?", $attribute->getAttributeId()),
        $connection->quoteInto("{$tableAlias}.store_id = ?", $collection->getStoreId()),
        $connection->quoteInto("{$tableAlias}.value in (?)",$value)
    );
     }

    $collection->getSelect()->join(
        array($tableAlias => $this->getMainTable()),
        implode(' AND ', $conditions),
        array()
    );

    //echo $collection->getSelect();

    return $this;
}
4

1 に答える 1

0

同様のことを行ったことがありますが、apply() メソッドを使用して結果をフィルタリングする Mage_Catalog_Model_Layer_Filter_Attribute クラスを書き直す必要があります。

于 2013-02-05T16:24:37.017 に答える