Skip to content

Commit f966156

Browse files
committed
Merge remote-tracking branch 'origin/MC-29864' into 2.4-develop-pr5
2 parents 37868a3 + b72a744 commit f966156

File tree

1 file changed

+12
-0
lines changed
  • app/code/Magento/CatalogSearch/Model/ResourceModel/Fulltext

1 file changed

+12
-0
lines changed

app/code/Magento/CatalogSearch/Model/ResourceModel/Fulltext/Collection.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,8 @@ public function addFieldToFilter($field, $condition = null)
385385
public function clear()
386386
{
387387
$this->searchResult = null;
388+
$this->setFlag('has_category_filter', false);
389+
388390
return parent::clear();
389391
}
390392

@@ -394,6 +396,8 @@ public function clear()
394396
protected function _reset()
395397
{
396398
$this->searchResult = null;
399+
$this->setFlag('has_category_filter', false);
400+
397401
return parent::_reset();
398402
}
399403

@@ -423,7 +427,11 @@ public function _loadEntities($printQuery = false, $logQuery = false)
423427
throw $e;
424428
}
425429

430+
$position = 0;
426431
foreach ($rows as $value) {
432+
if ($this->getFlag('has_category_filter')) {
433+
$value['cat_index_position'] = $position++;
434+
}
427435
$object = $this->getNewEmptyItem()->setData($value);
428436
$this->addItem($object);
429437
if (isset($this->_itemsById[$object->getId()])) {
@@ -432,6 +440,9 @@ public function _loadEntities($printQuery = false, $logQuery = false)
432440
$this->_itemsById[$object->getId()] = [$object];
433441
}
434442
}
443+
if ($this->getFlag('has_category_filter')) {
444+
$this->setFlag('has_category_filter', false);
445+
}
435446

436447
return $this;
437448
}
@@ -669,6 +680,7 @@ public function addCategoryFilter(\Magento\Catalog\Model\Category $category)
669680
if ($this->defaultFilterStrategyApplyChecker->isApplicable()) {
670681
parent::addCategoryFilter($category);
671682
} else {
683+
$this->setFlag('has_category_filter', true);
672684
$this->_productLimitationPrice();
673685
}
674686

0 commit comments

Comments
 (0)