Skip to content

Commit 4f0fb9e

Browse files
committed
ACP2E-3189: small improvements
1 parent c8f9ec6 commit 4f0fb9e

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

app/code/Magento/Sales/Model/ResourceModel/Report/Bestsellers.php

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ class Bestsellers extends AbstractReport
5555
*/
5656
protected $storeManager;
5757

58+
/**
59+
* @var array
60+
*/
61+
private array $rangesByQuery = [];
62+
5863
/**
5964
* @param Context $context
6065
* @param LoggerInterface $logger
@@ -215,14 +220,20 @@ private function clearTableRanges($table, $from = null, $to = null, $subSelect =
215220
*/
216221
private function getRange(Select $select): array
217222
{
218-
$connection = $this->getConnection();
219-
$range = [];
220-
try {
221-
$query = $connection->query($select);
222-
$range = $query->fetchAll(\Zend_Db::FETCH_COLUMN);
223-
} catch (\Exception $e) {
223+
$queryHash = sha1($select->__toString());
224+
if (!isset($this->rangesByQuery[$queryHash])) {
225+
226+
$connection = $this->getConnection();
227+
$range = [];
228+
try {
229+
$query = $connection->query($select);
230+
$range = $query->fetchAll(\Zend_Db::FETCH_COLUMN);
231+
} catch (\Exception $e) {
232+
}
233+
234+
$this->rangesByQuery[$queryHash] = $range;
224235
}
225-
return $range;
236+
return $this->rangesByQuery[$queryHash];
226237
}
227238

228239
/**

0 commit comments

Comments
 (0)