File tree Expand file tree Collapse file tree 1 file changed +7
-19
lines changed
app/code/Magento/Elasticsearch/Model/ResourceModel/Fulltext/Collection Expand file tree Collapse file tree 1 file changed +7
-19
lines changed Original file line number Diff line number Diff line change @@ -86,34 +86,22 @@ public function apply()
86
86
private function sliceItems (array $ items , int $ size , int $ currentPage ): array
87
87
{
88
88
if ($ size !== 0 ) {
89
- $ offset = $ this ->getOffset ($ currentPage , $ size );
90
89
$ itemsCount = count ($ items );
91
- if ($ this ->isOffsetOutOfRange ($ offset , $ size , $ itemsCount )) {
92
- $ offset = 0 ;
93
- }
94
90
$ maxAllowedPageNumber = ceil ($ itemsCount /$ size );
91
+ if ($ currentPage < 1 ) {
92
+ $ currentPage = 1 ;
93
+ }
95
94
if ($ currentPage > $ maxAllowedPageNumber ) {
96
- $ offset = $ this -> getOffset ( $ maxAllowedPageNumber, $ size ) ;
95
+ $ currentPage = $ maxAllowedPageNumber ;
97
96
}
98
- $ items = array_slice ($ items , $ offset , $ this ->size );
97
+
98
+ $ offset = $ this ->getOffset ($ currentPage , $ size );
99
+ $ items = array_slice ($ items , $ offset , $ size );
99
100
}
100
101
101
102
return $ items ;
102
103
}
103
104
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
-
117
105
/**
118
106
* Get offset for given page.
119
107
*
You can’t perform that action at this time.
0 commit comments