We have installed a extension for the Layered Navigation. Here we need to modify the logic for the product count.
We have already written code for the getting the count by overriding the the following page.
Mage/catalog/Model/Resource/Layer/Filter/Attribute.php
public function getCount($filter)
{
// clone select from collection with filters
$select = clone $filter->getLayer()->getProductCollection()
->addAttributeToFilter('is_master_record',1)
->addAttributeToFilter('num_of_child',array('gt' => 0))
->getSelect();
// reset columns, order and limitation conditions
$select->reset(Zend_Db_Select::COLUMNS);
$select->reset(Zend_Db_Select::ORDER);
$select->reset(Zend_Db_Select::LIMIT_COUNT);
$select->reset(Zend_Db_Select::LIMIT_OFFSET);
$connection = $this->_getReadAdapter();
$attribute = $filter->getAttributeModel();
$tableAlias = sprintf('%s_idx', $attribute->getAttributeCode());
$conditions = array(
"{$tableAlias}.entity_id = e.entity_id",
$connection->quoteInto("{$tableAlias}.attribute_id = ?", $attribute->getAttributeId()),
$connection->quoteInto("{$tableAlias}.store_id = ?", $filter->getStoreId()),
);
$select
->join(
array($tableAlias => $this->getMainTable()),
join(' AND ', $conditions),
array('value', 'count' => new Zend_Db_Expr("COUNT({$tableAlias}.entity_id)")))
->group("{$tableAlias}.value");
return $connection->fetchPairs($select);
}
This seems to be working while loading the page initially. However if user clicks in one of the filter, the logic in above page is not working instead its getting the count from some other function. It would be really helpful if someone could tell where is the logic for Selected Filter
In Layered Navigation
is located so that we can modify it.