@@ -385,6 +385,8 @@ public function addFieldToFilter($field, $condition = null)
385
385
public function clear ()
386
386
{
387
387
$ this ->searchResult = null ;
388
+ $ this ->setFlag ('has_category_filter ' , false );
389
+
388
390
return parent ::clear ();
389
391
}
390
392
@@ -394,6 +396,8 @@ public function clear()
394
396
protected function _reset ()
395
397
{
396
398
$ this ->searchResult = null ;
399
+ $ this ->setFlag ('has_category_filter ' , false );
400
+
397
401
return parent ::_reset ();
398
402
}
399
403
@@ -423,7 +427,11 @@ public function _loadEntities($printQuery = false, $logQuery = false)
423
427
throw $ e ;
424
428
}
425
429
430
+ $ position = 0 ;
426
431
foreach ($ rows as $ value ) {
432
+ if ($ this ->getFlag ('has_category_filter ' )) {
433
+ $ value ['cat_index_position ' ] = $ position ++;
434
+ }
427
435
$ object = $ this ->getNewEmptyItem ()->setData ($ value );
428
436
$ this ->addItem ($ object );
429
437
if (isset ($ this ->_itemsById [$ object ->getId ()])) {
@@ -432,6 +440,9 @@ public function _loadEntities($printQuery = false, $logQuery = false)
432
440
$ this ->_itemsById [$ object ->getId ()] = [$ object ];
433
441
}
434
442
}
443
+ if ($ this ->getFlag ('has_category_filter ' )) {
444
+ $ this ->setFlag ('has_category_filter ' , false );
445
+ }
435
446
436
447
return $ this ;
437
448
}
@@ -669,6 +680,7 @@ public function addCategoryFilter(\Magento\Catalog\Model\Category $category)
669
680
if ($ this ->defaultFilterStrategyApplyChecker ->isApplicable ()) {
670
681
parent ::addCategoryFilter ($ category );
671
682
} else {
683
+ $ this ->setFlag ('has_category_filter ' , true );
672
684
$ this ->_productLimitationPrice ();
673
685
}
674
686
0 commit comments