0

In layered navigation, when i select particular attribute, it gets disappeared from left side selection panel, so I want I should be able to select more than once. If I come to know from what collection it is coming, that will be helpful.

-Thanks in Advance.

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;
}
ANKIT
  • 341
  • 3
  • 13

1 Answers1

0

I've done something similar, and you have to rewrite the Mage_Catalog_Model_Layer_Filter_Attribute class, which uses the method apply() to filter results.

Tobias
  • 1,692
  • 12
  • 21
  • Thnx for your quick reply.I hv done that earlier but unsuccessful, if u can explain in brief that would be hellpful. – ANKIT Feb 06 '13 at 06:40
  • I am passing parameters in array so according to that I hv modified apply method. – ANKIT Feb 06 '13 at 13:32
  • Could you show your modified apply method? Update your question. – Tobias Feb 06 '13 at 14:26
  • So, you're currently direct apply the filter to collection, but that's exactly what Magento Core is doing aswell. You have to update the collection with your own where conditions, where all your possible values are checked by an OR and not AND – Tobias Feb 07 '13 at 09:27
  • could you call an assemble on your select object to see what he's really building there? – Tobias Feb 07 '13 at 12:22
  • It is returning correct results but i want the filter selection as multiselect....so plz mail me or provide me your example. – ANKIT Feb 07 '13 at 13:18
  • I'm not sure at which point you're stuck now. Did you change your template to a multiselect? Your request gets these multiselected values? And they're applied correctly? – Tobias Feb 07 '13 at 13:41
  • i hv changed template also....can i get ur mail id so that i can tell u my code in detail.... – ANKIT Feb 08 '13 at 05:28
  • you could add your code details in your question, so everyone can participate – Tobias Feb 08 '13 at 07:52