Skip to content

Commit c8a7ff9

Browse files
committed
MAGE-569 Feature flag category navigation for future enablement via custom renderer
1 parent ffe173b commit c8a7ff9

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

Block/Configuration.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99

1010
class Configuration extends Algolia implements CollectionDataSourceInterface
1111
{
12+
//Placeholder for future implementation (requires customer renderer for hierarchicalMenu widget)
13+
private const IS_CATEGORY_NAVIGATION_ENABLED = false;
14+
1215
public function isSearchPage()
1316
{
1417
if ($this->getConfigHelper()->isInstantEnabled()) {
@@ -57,7 +60,7 @@ protected function getChildCategoryUrls(\Magento\Catalog\Model\Category $cat, st
5760
}
5861

5962
foreach ($cat->getChildrenCategories() as $child) {
60-
$key = $parent ? $parent . $this->getConfigHelper()->getCategorySeparator() . $child->getName() : $child ->getName();
63+
$key = $parent ? $parent . $this->getConfigHelper()->getCategorySeparator($this->getStoreId()) . $child->getName() : $child ->getName();
6164
$arr[$key]['url'] = $child->getUrl();
6265
$arr = array_merge($arr, $this->getChildCategoryUrls($child, $key, $arr));
6366
}
@@ -123,7 +126,9 @@ public function getConfiguration()
123126

124127
if ($category && $category->getDisplayMode() !== 'PAGE') {
125128
$category->getUrlInstance()->setStore($this->getStoreId());
126-
$childCategories = $this->getChildCategoryUrls($category);
129+
if (self::IS_CATEGORY_NAVIGATION_ENABLED) {
130+
$childCategories = $this->getChildCategoryUrls($category);
131+
}
127132

128133
$categoryId = $category->getId();
129134

@@ -180,7 +185,6 @@ public function getConfiguration()
180185
}
181186

182187
$attributesToFilter = $config->getAttributesToFilter($customerGroupId);
183-
184188
$algoliaJsConfig = [
185189
'instant' => [
186190
'enabled' => $config->isInstantEnabled(),
@@ -192,7 +196,8 @@ public function getConfiguration()
192196
'isSearchBoxEnabled' => $config->isInstantSearchBoxEnabled(),
193197
'isVisualMerchEnabled' => $config->isVisualMerchEnabled(),
194198
'categorySeparator' => $config->getCategorySeparator(),
195-
'categoryPageIdAttribute' => $config->getCategoryPageIdAttributeName()
199+
'categoryPageIdAttribute' => $config->getCategoryPageIdAttributeName(),
200+
'isCategoryNavigationEnabled' => self::IS_CATEGORY_NAVIGATION_ENABLED
196201
],
197202
'autocomplete' => [
198203
'enabled' => $config->isAutoCompleteEnabled(),

view/frontend/web/instantsearch.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ requirejs(['algoliaBundle', 'Magento_Catalog/js/price-utils'], function (algolia
258258
**/
259259
currentRefinements: {
260260
container: '#current-refinements',
261+
// TODO: Remove this - it does nothing
261262
templates: {
262263
item: $('#current-refinements-template').html()
263264
},
@@ -464,12 +465,12 @@ requirejs(['algoliaBundle', 'Magento_Catalog/js/price-utils'], function (algolia
464465
transformItems(items) {
465466
return (algoliaConfig.isCategoryPage)
466467
? findRoot(items).map(
468+
// TODO: Make recursive and implement custom renderer
467469
item => {
468-
if (true) {
469-
item.categoryUrl = algoliaConfig.request.childCategories[item.value]['url'];
470-
}
471-
console.log('item:', item);
472-
return item;
470+
return {
471+
...item,
472+
categoryUrl: algoliaConfig.instant.isCategoryNavigationEnabled ? algoliaConfig.request.childCategories[item.value]['url'] : ''
473+
};
473474
}
474475
)
475476
: items;

0 commit comments

Comments
 (0)