I am using "Layered Navigation SEO" from magento connect. It's working flawlessly.
But I want the filters(with results) to be displayed always. My requirement is not similar to other questions found here.
for example...
In the computers category (working with sample data) there are 4 brands and three colors (black, brown and silver) I select "Apple" as brand the available colors would be silver alone, but I want to display all the 3 colors as before (remember... NOT all the colors like pink, magenta, etc.) If I select filter(no results) all colors like white, magento, pink, etc. will be displayed, which I don't want
I want only the filters which are related to category initially. I am new to magento coding
Any help?
If more clarity is needed I'll be able to provide...
in app\code\local\Catalin\SEO\Model\Catalog\Resource\Layer\Filter\Attribute.php
edit public function getCount($filter)
goto last line
change return $connection->fetchPairs($select); to...
$pairCarry = $connection->fetchPairs($select);
$pairCarryfin = $this->checkTheAttributes($pairCarry, $tableAlias, $attribute);
return $pairCarryfin;
then add the function below it...
public function checkTheAttributes($pairCarry, $tableAlias, $attribute){
$category = Mage::registry('current_category');
if($category){
$query = "SELECT DISTINCT `$tableAlias`.`value`, COUNT($tableAlias.entity_id) AS `count` FROM `catalog_product_entity` AS `e`
INNER JOIN `catalog_category_product_index` AS `cat_index` ON cat_index.product_id=e.entity_id AND cat_index.store_id=".$category->getStoreId()." AND cat_index.visibility IN(2, 4) AND cat_index.category_id='".$category->getId()."'
INNER JOIN `catalog_product_index_price` AS `price_index` ON price_index.entity_id = e.entity_id AND price_index.website_id = '1' AND price_index.customer_group_id = 0
INNER JOIN `catalog_product_index_eav` AS `$tableAlias` ON $tableAlias.entity_id = e.entity_id AND $tableAlias.attribute_id = '".$attribute->getAttributeId()."' AND $tableAlias.store_id = '".$category->getStoreId()."' GROUP BY `$tableAlias`.`value`";
}
else{
$query = "SELECT DISTINCT `$tableAlias`.`value`, COUNT($tableAlias.entity_id) AS `count` FROM `catalog_product_entity` AS `e`
INNER JOIN `catalog_category_product_index` AS `cat_index` ON cat_index.product_id=e.entity_id AND cat_index.store_id=1 AND cat_index.visibility IN(2, 4)
INNER JOIN `catalog_product_index_price` AS `price_index` ON price_index.entity_id = e.entity_id AND price_index.website_id = '1' AND price_index.customer_group_id = 0
INNER JOIN `catalog_product_index_eav` AS `$tableAlias` ON $tableAlias.entity_id = e.entity_id AND $tableAlias.attribute_id = '".$attribute->getAttributeId()."' AND $tableAlias.store_id = 1 GROUP BY `$tableAlias`.`value`";
}
$connection = $this->_getReadAdapter();
$pairCarry_inter = $connection->fetchPairs($query);
if(!empty($pairCarry)){
$odd = array_diff_key($pairCarry_inter, $pairCarry);
if(!empty($odd)){
foreach($odd as $k=>$v){
$odd[$k] = 0;
}
$pairCarry_inter = $pairCarry + $odd;
}
}
else{
foreach($pairCarry_inter as $k => $v){
$pairCarry_inter[$k] = 0;
}
}
$pairCarry_complete = $pairCarry_inter;
return $pairCarry_complete;
}