{$productCategories = []}> <{$productBrands = []}> <{$ratings = [0,0,0,0,0]}> <{* Pretty inefficient way to get all the categories/brands/ratings of the products in this category *}> <{* This is used to populate the filter *}> <{foreach $products as $product}> <{if $productRating = $product->getAvgRating()}> <{$ratingIndex = $productRating-1}> <{$ratings[$ratingIndex] = $ratings[$ratingIndex]+1}> <{/if}> <{if $categories = $product->getCategories()}> <{foreach $categories as $cat}> <{if $catName = $cat->getName()}> <{append 'productCategories' $catName}> <{/if}> <{/foreach}> <{/if}> <{if $brand = $product->getBrandName()}> <{append 'productBrands' $brand}> <{/if}> <{/foreach}> <{* Count how many times each category appears in $productCategories *}> <{counter values=$productCategories assign="counts"}> <{foreach $productCategories as $productCategory}> <{if !isset($counts[$productCategory])}> <{$counts[$productCategory] = 0}> <{/if}> <{$counts[$productCategory] = $counts[$productCategory]+1}> <{/foreach}> <{* Count how many times each brand appears in $productBrands *}> <{counter values=$productBrands assign="brandCounts"}> <{foreach $productBrands as $productBrand}> <{if !isset($brandCounts[$productBrand])}> <{$brandCounts[$productBrand] = 0}> <{/if}> <{$brandCounts[$productBrand] = $brandCounts[$productBrand]+1}> <{/foreach}> <{if $category}> <{$pageType = $category}> <{elseif $landing_page}> <{$pageType = $landing_page}> <{/if}> <{if $promoImage = $pageType->getExtensionValue('category_campaign')}>
<{/if}> <{* *}>