2013-01-16 35 views
0

我使用magento connect的「Layered Navigation SEO」。 它工作完美無瑕。如何在分層導航中顯示*所有*濾鏡?

但我想過濾器(結果)總是顯示。我的要求與此處找到的其他問題不相似。

例如...

在計算機類(樣本數據的工作)有4個品牌,三種顏色(黑色,棕色和銀色) 我選擇「蘋果」爲品牌提供的這些顏色會銀色,但我想像以前一樣顯示所有的3種顏色(請記住...不是所有的顏色,如粉紅色,洋紅色等) 如果我選擇過濾器(無結果),所有顏色如白色,桃紅色,粉紅色等將會顯示,我不想要

我只想要最初與類別有關的過濾器。 我是新來magento編碼

任何幫助嗎?

如果需要更清楚我將能夠提供...

回答

1
在app \代碼

\本地\克特林\ SEO \型號\目錄\資源\圖層\過濾器\ Attribute.php

編輯公共職能getCount將($過濾器)

轉到最後一行

改變返回$連接 - > fetchPairs($選擇);到...

$pairCarry = $connection->fetchPairs($select); 
$pairCarryfin = $this->checkTheAttributes($pairCarry, $tableAlias, $attribute); 
return $pairCarryfin; 

然後在它下面添加功能...

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; 
} 
相關問題