Skip to content

Commit 9aca18f

Browse files
committed
MC-22852: 24/36 product limit on Category page occur fatal
1 parent 316ce38 commit 9aca18f

File tree

1 file changed

+7
-19
lines changed

1 file changed

+7
-19
lines changed

app/code/Magento/Elasticsearch/Model/ResourceModel/Fulltext/Collection/SearchResultApplier.php

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -86,34 +86,22 @@ public function apply()
8686
private function sliceItems(array $items, int $size, int $currentPage): array
8787
{
8888
if ($size !== 0) {
89-
$offset = $this->getOffset($currentPage, $size);
9089
$itemsCount = count($items);
91-
if ($this->isOffsetOutOfRange($offset, $size, $itemsCount)) {
92-
$offset = 0;
93-
}
9490
$maxAllowedPageNumber = ceil($itemsCount/$size);
91+
if ($currentPage < 1) {
92+
$currentPage = 1;
93+
}
9594
if ($currentPage > $maxAllowedPageNumber) {
96-
$offset = $this->getOffset($maxAllowedPageNumber, $size);
95+
$currentPage = $maxAllowedPageNumber;
9796
}
98-
$items = array_slice($items, $offset, $this->size);
97+
98+
$offset = $this->getOffset($currentPage, $size);
99+
$items = array_slice($items, $offset, $size);
99100
}
100101

101102
return $items;
102103
}
103104

104-
/**
105-
* Check that offset could be applied for search result items.
106-
*
107-
* @param int $offset
108-
* @param int $size
109-
* @param int $itemsCount
110-
* @return bool
111-
*/
112-
private function isOffsetOutOfRange(int $offset, int $size, int $itemsCount): bool
113-
{
114-
return $offset < 0 || $itemsCount <= $size;
115-
}
116-
117105
/**
118106
* Get offset for given page.
119107
*

0 commit comments

Comments
 (0)