Skip to content

Issue #17: Exclude items with zero counts from filter items count calculation #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 12, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ protected function _getFilter($attribute, $attributeFacets)
{
$filter = new Varien_Object();
$filter->setName($attribute->getStoreLabel());
$filter->setItemsCount(sizeof($attributeFacets));
$filter->setItemsCount(sizeof(array_filter($attributeFacets)));
$filter->setIdentifier($attribute->getAttributeCode());
$filter->setHtml(
$this->_getFilterBlock()
Expand All @@ -155,7 +155,7 @@ protected function _getIntervalFilter($attribute, $attributeFacetData)
{
$filter = new Varien_Object();
$filter->setName($attribute->getStoreLabel());
$filter->setItemsCount(sizeof($attributeFacetData));
$filter->setItemsCount(sizeof(array_filter($attributeFacetData)));
$filter->setIdentifier($attribute->getAttributeCode());
$filter->setHtml(
$this->_getFilterBlock()
Expand All @@ -176,7 +176,7 @@ protected function _getRangeFilter($attribute, $attributeFacetData)
{
$filter = new Varien_Object();
$filter->setName($attribute->getStoreLabel());
$filter->setItemsCount(sizeof($attributeFacetData['counts']));
$filter->setItemsCount(sizeof(array_filter($attributeFacetData['counts'])));
$filter->setIdentifier($attribute->getAttributeCode());
$filter->setHtml(
$this->_getFilterBlock()
Expand All @@ -196,7 +196,7 @@ protected function _getCategoryFilter($categoryFacets)
{
$filter = new Varien_Object();
$filter->setName(Mage::helper('catalog')->__('Category'));
$filter->setItemsCount(sizeof($categoryFacets));
$filter->setItemsCount(sizeof(array_filter($categoryFacets)));
$filter->setIdentifier('category');

/** @var IntegerNet_Solr_Block_Result_Layer_Filter $filterBlock */
Expand Down Expand Up @@ -251,4 +251,4 @@ protected function _getFilterBlock()
{
return $this->getChild('filter')->reset();
}
}
}