solr-magento1 icon indicating copy to clipboard operation
solr-magento1 copied to clipboard

Category filter sort order

Open tim-bezhashvyly opened this issue 7 years ago • 2 comments

Not sure if it is intentional but category filter here will be ordered by Magento category sort order and not facet counts.

If not a solution could be the following:

$childrenCategories = iterator_to_array($this->_getCurrentChildrenCategories());

foreach ($categoryFacets as $childCategoryId => $count) {
    if (isset($childrenCategories[$childCategoryId])) {

        $item = new Varien_Object();
        $item->setCount($count);
        $optionLabel = $childrenCategories[$childCategoryId]->getName();
        $item->setLabel($this->_getCheckboxHtml('cat', $childCategoryId) . ' ' . $optionLabel);
        $item->setUrl($this->_getUrl($childCategoryId));
        $item->setIsChecked($this->_isSelected('cat', $childCategoryId));
        $item->setType('category');
        $item->setOptionId($childCategoryId);

        Mage::dispatchEvent('integernet_solr_filter_item_create', array(
            'item' => $item,
            'solr_result' => $this->_getSolrResult(),
            'type' => 'category',
            'entity_id' => $childCategoryId,
            'entity' => $childrenCategories[$childCategoryId],
        ));

        if (!$item->getIsDisabled()) {
            $this->_categoryFilterItems[$optionLabel] = $item;
        }
    }
}

tim-bezhashvyly avatar Mar 27 '17 18:03 tim-bezhashvyly

@schmengler @sriesterer Your Opinion? Should category filters be sorted by number of results or by Magento sort order?

avstudnitz avatar Apr 18 '17 12:04 avstudnitz

IMHO, category sort order makes sense, but I understand that some would prefer sort by count - so if we change that, it should be configurable.

schmengler avatar Apr 28 '17 07:04 schmengler