0

magento connect の「Layered Navigation SEO」を使用しています。問題なく動作しています。

しかし、フィルター(結果付き)を常に表示したい。私の要件は、ここにある他の質問と似ていません。

例えば...

コンピューター カテゴリ (サンプル データでの作業) には、4 つのブランドと 3 つの色 (黒、茶色、シルバー) があります。ブランドとして「Apple」を選択します。使用可能な色はシルバーだけですが、以前のように 3 色すべてを表示したいです。 (覚えておいてください...ピンク、マゼンタなどのすべての色ではありません)フィルターを選択すると(結果なし)、白、マジェント、ピンクなどのすべての色が表示されますが、これは望ましくありません

最初はカテゴリに関連するフィルターのみが必要です。私はmagentoコーディングが初めてです

何か助けはありますか?

より明確にする必要がある場合は、提供できます...

4

1 に答える 1

1

app\code\local\Catalin\SEO\Model\Catalog\Resource\Layer\Filter\Attribute.php 内

パブリック関数 getCount($filter) を編集

最後の行に移動

return $connection->fetchPairs($select); を変更します。に...

$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;
}
于 2013-04-30T11:51:23.907 に答える