Skip to content

Commit 1cb0f83

Browse files
committed
Fix issue with category api recursively including subcategories, add sort order to facet attributes
1 parent 0558516 commit 1cb0f83

File tree

3 files changed

+29
-10
lines changed

3 files changed

+29
-10
lines changed

code/Block/Adminhtml/System/Config/Form/AttributeLabels.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
77
$html = '<div class="hor-scroll"><table class="dynamic-grid" id="attribute-labels-table" cellspacing="0"><tbody>';
88

99
$html .= '<tr>';
10-
$html .= '<th>Default</th>';
10+
$html .= '<th>' . $this->__('Default') .'</th>';
1111
$html .= '<th>' . $this->getStore()->getName() . '</th>';
12+
$html .= '<th>' . $this->__('Sort Order') . '</th>';
1213
$html .= '</tr>';
1314

1415
//Loop over specified facet attributes
@@ -21,7 +22,8 @@ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
2122

2223
$html .= '<tr>';
2324
$html .= '<td><input id="' . $element->getHtmlId() . '_orig" class="input-text disabled" value="' . $attribute . '" type="text" readonly></td>';
24-
$html .= '<td><input id="' . $element->getHtmlId() . '" class="input-text" name="' . $element->getName() . '[' . $attribute . ']" value="' . $value . '' . '" type="text"></td>';
25+
$html .= '<td><input id="' . $element->getHtmlId() . '" class="input-text" name="' . $element->getName() . '[' . $attribute . '][label]" value="' . $value['label'] . '' . '" type="text"></td>';
26+
$html .= '<td><input id="' . $element->getHtmlId() . '" class="input-text" name="' . $element->getName() . '[' . $attribute . '][sort_order]" value="' . $value['sort_order'] . '' . '" type="text"></td>';
2527
$html .= '</tr>';
2628
}
2729

code/Block/Search.php

+24-7
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,35 @@ public function getSpanAttributes()
3939
];
4040

4141
if (Mage::getStoreConfigFlag(Clerk_Clerk_Model_Config::XML_PATH_FACETED_SEARCH_ENABLED)) {
42-
if ($attributes = Mage::getStoreConfig(Clerk_Clerk_Model_Config::XML_PATH_FACETED_SEARCH_ATTRIBUTES)) {
43-
$spanAttributes['data-facets-target'] = "#clerk-search-filters";
44-
$spanAttributes['data-facets-attributes'] = '["' . str_replace(',', '","', $attributes) . '"]';
42+
$spanAttributes['data-facets-target'] = "#clerk-search-filters";
43+
44+
if ($titles = Mage::getStoreConfig(Clerk_Clerk_Model_Config::XML_PATH_FACETED_SEARCH_TITLES)) {
45+
$titles = json_decode($titles, true);
46+
47+
// sort by sort_order
48+
uasort($titles, function($a, $b) {
49+
return $a['sort_order'] > $b['sort_order'];
50+
});
51+
52+
$spanAttributes['data-facets-titles'] = json_encode(array_filter(array_combine(array_keys($titles), array_column($titles, 'label'))));
53+
$spanAttributes['data-facets-attributes'] = json_encode(array_keys($titles));
4554

4655
if ($multiselectAttributes = Mage::getStoreConfig(Clerk_Clerk_Model_Config::XML_PATH_FACETED_SEARCH_MULTISELECT_ATTRIBUTES)) {
4756
$spanAttributes['data-facets-multiselect-attributes'] = '["' . str_replace(',', '","', $multiselectAttributes) . '"]';
4857
}
49-
50-
if ($titles = Mage::getStoreConfig(Clerk_Clerk_Model_Config::XML_PATH_FACETED_SEARCH_TITLES)) {
51-
$spanAttributes['data-facets-titles'] = $titles;
52-
}
5358
}
59+
60+
// if ($attributes = Mage::getStoreConfig(Clerk_Clerk_Model_Config::XML_PATH_FACETED_SEARCH_ATTRIBUTES)) {
61+
// $spanAttributes['data-facets-attributes'] = '["' . str_replace(',', '","', $attributes) . '"]';
62+
//
63+
// if ($multiselectAttributes = Mage::getStoreConfig(Clerk_Clerk_Model_Config::XML_PATH_FACETED_SEARCH_MULTISELECT_ATTRIBUTES)) {
64+
// $spanAttributes['data-facets-multiselect-attributes'] = '["' . str_replace(',', '","', $multiselectAttributes) . '"]';
65+
// }
66+
//
67+
// if ($titles = Mage::getStoreConfig(Clerk_Clerk_Model_Config::XML_PATH_FACETED_SEARCH_TITLES)) {
68+
// $spanAttributes['data-facets-titles'] = $titles;
69+
// }
70+
// }
5471
}
5572

5673

code/controllers/ApiController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public function categoryAction()
132132

133133
foreach ($categories as $category) {
134134
//Get children categories
135-
$children = $category->getResource()->getChildren($category);
135+
$children = $category->getResource()->getChildren($category, false);
136136

137137
$data = [
138138
'id' => (int) $category->getId(),

0 commit comments

Comments
 (0)