solr-magento1
solr-magento1 copied to clipboard
Category filter sort order
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;
}
}
}
@schmengler @sriesterer Your Opinion? Should category filters be sorted by number of results or by Magento sort order?
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.