Skip to content

Commit faafb28

Browse files
authored
merge magento/2.3-develop into magento-engcom/memory-leak-calculation-improvement
2 parents 01f84ee + 439d2ab commit faafb28

File tree

3 files changed

+126
-3
lines changed

3 files changed

+126
-3
lines changed

app/code/Magento/Catalog/Test/Mftf/Test/AdminCheckPaginationInStorefrontTest.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616
<severity value="CRITICAL"/>
1717
<group value="mtf_migrated"/>
1818
<group value="Catalog"/>
19-
<skip>
20-
<issueId value="MC-21962"/>
21-
</skip>
2219
</annotations>
2320
<before>
2421
<magentoCLI stepKey="setFlatCatalogCategory" command="config:set catalog/frontend/flat_catalog_category 1 "/>

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

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
use Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection\SearchResultApplierFactory;
2828
use Magento\Framework\App\ObjectManager;
2929
use Magento\Framework\Api\Search\SearchResultInterface;
30+
use Magento\Search\Model\EngineResolver;
3031

3132
/**
3233
* Advanced search collection
@@ -40,6 +41,11 @@
4041
*/
4142
class Collection extends \Magento\Catalog\Model\ResourceModel\Product\Collection
4243
{
44+
/**
45+
* Config search engine path.
46+
*/
47+
private const SEARCH_ENGINE_VALUE_PATH = 'catalog/search/engine';
48+
4349
/**
4450
* List Of filters
4551
* @var array
@@ -344,6 +350,63 @@ protected function _renderFiltersBefore()
344350
parent::_renderFiltersBefore();
345351
}
346352

353+
/**
354+
* @inheritDoc
355+
*/
356+
public function clear()
357+
{
358+
$this->searchResult = null;
359+
return parent::clear();
360+
}
361+
362+
/**
363+
* @inheritDoc
364+
*/
365+
protected function _reset()
366+
{
367+
$this->searchResult = null;
368+
return parent::_reset();
369+
}
370+
371+
/**
372+
* @inheritdoc
373+
*/
374+
public function _loadEntities($printQuery = false, $logQuery = false)
375+
{
376+
$this->getEntity();
377+
378+
$currentSearchEngine = $this->_scopeConfig->getValue(self::SEARCH_ENGINE_VALUE_PATH);
379+
if ($this->_pageSize && $currentSearchEngine === EngineResolver::CATALOG_SEARCH_MYSQL_ENGINE) {
380+
$this->getSelect()->limitPage($this->getCurPage(), $this->_pageSize);
381+
}
382+
383+
$this->printLogQuery($printQuery, $logQuery);
384+
385+
try {
386+
/**
387+
* Prepare select query
388+
* @var string $query
389+
*/
390+
$query = $this->getSelect();
391+
$rows = $this->_fetchAll($query);
392+
} catch (\Exception $e) {
393+
$this->printLogQuery(false, true, $query);
394+
throw $e;
395+
}
396+
397+
foreach ($rows as $value) {
398+
$object = $this->getNewEmptyItem()->setData($value);
399+
$this->addItem($object);
400+
if (isset($this->_itemsById[$object->getId()])) {
401+
$this->_itemsById[$object->getId()][] = $object;
402+
} else {
403+
$this->_itemsById[$object->getId()] = [$object];
404+
}
405+
}
406+
407+
return $this;
408+
}
409+
347410
/**
348411
* Get total records resolver.
349412
*

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

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
use Magento\Framework\Exception\LocalizedException;
2828
use Magento\Framework\App\ObjectManager;
2929
use Magento\Catalog\Model\ResourceModel\Product\Collection\ProductLimitationFactory;
30+
use Magento\Search\Model\EngineResolver;
3031

3132
/**
3233
* Fulltext Collection
@@ -41,6 +42,11 @@
4142
*/
4243
class Collection extends \Magento\Catalog\Model\ResourceModel\Product\Collection
4344
{
45+
/**
46+
* Config search engine path.
47+
*/
48+
private const SEARCH_ENGINE_VALUE_PATH = 'catalog/search/engine';
49+
4450
/**
4551
* @var QueryResponse
4652
* @deprecated 100.1.0
@@ -373,6 +379,63 @@ public function addFieldToFilter($field, $condition = null)
373379
return $this;
374380
}
375381

382+
/**
383+
* @inheritDoc
384+
*/
385+
public function clear()
386+
{
387+
$this->searchResult = null;
388+
return parent::clear();
389+
}
390+
391+
/**
392+
* @inheritDoc
393+
*/
394+
protected function _reset()
395+
{
396+
$this->searchResult = null;
397+
return parent::_reset();
398+
}
399+
400+
/**
401+
* @inheritdoc
402+
*/
403+
public function _loadEntities($printQuery = false, $logQuery = false)
404+
{
405+
$this->getEntity();
406+
407+
$currentSearchEngine = $this->_scopeConfig->getValue(self::SEARCH_ENGINE_VALUE_PATH);
408+
if ($this->_pageSize && $currentSearchEngine === EngineResolver::CATALOG_SEARCH_MYSQL_ENGINE) {
409+
$this->getSelect()->limitPage($this->getCurPage(), $this->_pageSize);
410+
}
411+
412+
$this->printLogQuery($printQuery, $logQuery);
413+
414+
try {
415+
/**
416+
* Prepare select query
417+
* @var string $query
418+
*/
419+
$query = $this->getSelect();
420+
$rows = $this->_fetchAll($query);
421+
} catch (\Exception $e) {
422+
$this->printLogQuery(false, true, $query);
423+
throw $e;
424+
}
425+
426+
foreach ($rows as $value) {
427+
$object = $this->getNewEmptyItem()->setData($value);
428+
$this->addItem($object);
429+
if (isset($this->_itemsById[$object->getId()])) {
430+
$this->_itemsById[$object->getId()][] = $object;
431+
} else {
432+
$this->_itemsById[$object->getId()] = [$object];
433+
}
434+
}
435+
436+
return $this;
437+
}
438+
376439
/**
377440
* Add search query filter
378441
*

0 commit comments

Comments
 (0)