@@ -261,26 +261,35 @@ requirejs(['algoliaBundle', 'Magento_Catalog/js/price-utils'], function (algolia
261
261
templates : {
262
262
item : $ ( '#current-refinements-template' ) . html ( )
263
263
} ,
264
- includedAttributes : attributes . map ( function ( attribute ) {
265
- if ( ! ( algoliaConfig . isCategoryPage && attribute . name . indexOf ( 'categories' ) > - 1 ) ) {
264
+ includedAttributes : attributes . map ( attribute => {
265
+ console . warn ( "Refinement:" , attribute ) ;
266
+ if ( attribute . name . indexOf ( 'categories' ) === - 1
267
+ || algoliaConfig . instant . isVisualMerchEnabled
268
+ || ! algoliaConfig . isCategoryPage )
266
269
return attribute . name ;
267
- }
268
270
} ) ,
269
- transformItems : function ( items ) {
270
- return items . map ( function ( item ) {
271
- var attribute = attributes . filter ( function ( _attribute ) {
272
- return item . attribute === _attribute . name
273
- } ) [ 0 ] ;
274
- if ( ! attribute ) return item ;
275
- item . label = attribute . label ;
276
- item . refinements . forEach ( function ( refinement ) {
277
- if ( refinement . type !== 'hierarchical' ) return refinement ;
278
- var levels = refinement . label . split ( algoliaConfig . instant . categorySeparator ) ;
279
- var lastLevel = levels [ levels . length - 1 ] ;
280
- refinement . label = lastLevel ;
281
- } ) ;
282
- return item ;
283
- } )
271
+ transformItems : items => {
272
+ console . log ( "%cRefinement transform:%o" , 'color:green;background:yellow' , items ) ;
273
+ return items
274
+ . filter ( item => {
275
+ return ! algoliaConfig . isCategoryPage
276
+ || item . refinements . filter ( refinement => refinement . value !== algoliaConfig . request . path ) . length ; // do not expose the category root
277
+ } )
278
+ . map ( item => {
279
+ const attribute = attributes . filter ( _attribute => {
280
+ return item . attribute === _attribute . name
281
+ } ) [ 0 ] ;
282
+ if ( ! attribute ) return item ;
283
+ item . label = attribute . label ;
284
+ item . refinements . forEach ( function ( refinement ) {
285
+ if ( refinement . type !== 'hierarchical' ) return refinement ;
286
+
287
+ const levels = refinement . label . split ( algoliaConfig . instant . categorySeparator ) ;
288
+ const lastLevel = levels [ levels . length - 1 ] ;
289
+ refinement . label = lastLevel ;
290
+ } ) ;
291
+ return item ;
292
+ } )
284
293
}
285
294
} ,
286
295
0 commit comments