Skip to content

Commit cd946e3

Browse files
author
OlgaVasyltsun
committed
MC-36048: Unexpected behavior of sorting in the Magento Admin Panel
1 parent 70c5c2f commit cd946e3

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Theme\Plugin\Data;
9+
10+
/**
11+
* Plugin to return real current page even if it greater then collection size.
12+
*
13+
* It is necessary to return no values when we reached the last page for api requests
14+
*/
15+
class Collection
16+
{
17+
public function afterGetCurPage(\Magento\Framework\Data\Collection $subject, int $result, int $displacement = 0)
18+
{
19+
if ($result > $subject->getLastPageNumber()) {
20+
$result = $subject->getLastPageNumber();
21+
}
22+
23+
return $result;
24+
}
25+
26+
}

app/code/Magento/Theme/etc/adminhtml/di.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,7 @@
4141
</argument>
4242
</arguments>
4343
</type>
44+
<type name="Magento\Framework\Data\Collection">
45+
<plugin name="currentPageDetection" type="Magento\Theme\Plugin\Data\Collection" />
46+
</type>
4447
</config>

app/code/Magento/Theme/etc/frontend/di.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,8 @@
3737
<argument name="filePath" xsi:type="string">css/critical.css</argument>
3838
</arguments>
3939
</type>
40+
41+
<type name="Magento\Framework\Data\Collection">
42+
<plugin name="currentPageDetection" type="Magento\Theme\Plugin\Data\Collection" />
43+
</type>
4044
</config>

0 commit comments

Comments
 (0)