Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/2.4-develop' into Hammer-Platefo…
Browse files Browse the repository at this point in the history
…rm-Health-04Sept24
  • Loading branch information
glo71317 committed Sep 11, 2024
2 parents 7761a2e + 44cef3a commit 9656b96
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 20 deletions.
26 changes: 20 additions & 6 deletions app/code/Magento/Ui/Model/Export/ConvertToCsv.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,33 @@ public function getCsvFile()
$searchCriteria = $dataProvider->getSearchCriteria()
->setCurrentPage($i)
->setPageSize($this->pageSize);
$totalCount = (int) $dataProvider->getSearchResult()->getTotalCount();
$totalPagesCount = (int) ceil($totalCount / $this->pageSize);
while ($i <= $totalPagesCount) {
// setTotalCount to prevent total count from being calculated in loop

$totalCount = null;
$totalPagesCount = null;

do {
$searchResult = $dataProvider->getSearchResult();
$searchResult->setTotalCount($totalCount);
$items = $searchResult->getItems();

if ($totalCount === null) { // get total count only once
$totalCount = $searchResult->getTotalCount();
$totalPagesCount = (int) ceil($totalCount / $this->pageSize);
}

// call setTotalCount to prevent total count from being calculate in subsequent iterations of this loop
$searchResult->setTotalCount($totalCount);
// Ensure $items is always an array
if ($items === null) {
$items = [];
}
foreach ($items as $item) {
$this->metadataProvider->convertDate($item, $component->getName());
$stream->writeCsv($this->metadataProvider->getRowData($item, $fields, $options));
}

$searchCriteria->setCurrentPage(++$i);
}
} while ($i <= $totalPagesCount);

$stream->unlock();
$stream->close();

Expand Down
17 changes: 10 additions & 7 deletions app/code/Magento/Ui/Test/Unit/Model/Export/ConvertToCsvTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ protected function setUp(): void
);
}

/**
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function testGetCsvFile()
{
$componentName = 'component_name';
Expand Down Expand Up @@ -142,7 +145,7 @@ public function testGetCsvFile()
->method('getFields')
->with($this->component)
->willReturn([]);
$this->metadataProvider->expects($this->exactly(2))
$this->metadataProvider->expects($this->any())
->method('getRowData')
->willReturnCallback(
function ($arg1, $arg2, $arg3) use ($document1, $document2, $data) {
Expand All @@ -153,7 +156,7 @@ function ($arg1, $arg2, $arg3) use ($document1, $document2, $data) {
}
}
);
$this->metadataProvider->expects($this->exactly(2))
$this->metadataProvider->expects($this->any())
->method('convertDate')
->willReturnCallback(
function ($arg1, $arg2) use ($document1, $document2, $componentName) {
Expand Down Expand Up @@ -245,25 +248,25 @@ private function mockComponent(string $componentName, array $page1Items, array $
->method('getDataProvider')
->willReturn($dataProvider);

$dataProvider->expects($this->exactly(3))
$dataProvider->expects($this->exactly(2))
->method('getSearchResult')
->willReturnOnConsecutiveCalls($searchResult0, $searchResult1, $searchResult2);

$dataProvider->expects($this->once())
->method('getSearchCriteria')
->willReturn($searchCriteria);

$searchResult1->expects($this->once())
$searchResult1->expects($this->any())
->method('setTotalCount');

$searchResult2->expects($this->once())
$searchResult2->expects($this->any())
->method('setTotalCount');

$searchResult1->expects($this->once())
$searchResult1->expects($this->any())
->method('getItems')
->willReturn($page1Items);

$searchResult2->expects($this->once())
$searchResult2->expects($this->any())
->method('getItems')
->willReturn($page2Items);

Expand Down
9 changes: 9 additions & 0 deletions app/code/Magento/UrlRewrite/Model/UrlRewrite.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,15 @@ private function getFinalTargetUrlRewrite(string $path, int $storeId): ?UrlRewri
]
);

// to manage accent characters in URL rewrite
if ($urlRewriteTarget) {
$planeChars = iconv('UTF-8', 'ISO-8859-1//IGNORE', $urlRewriteTarget->getRequestPath());

if ($planeChars !== $urlRewriteTarget->getRequestPath()) {
$urlRewriteTarget = null;
}
}

while ($urlRewriteTarget &&
$urlRewriteTarget->getTargetPath() !== $urlRewriteTarget->getRequestPath() &&
$urlRewriteTarget->getRedirectType() > 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,6 @@
padding: @page-main-actions__padding;
}

.actions-scrollable {
.page-actions {
display: flex;
overflow-x: auto;
}
}

.page-main-actions {
display: flex;
margin: 0 0 @indent__l;
Expand Down

0 comments on commit 9656b96

Please sign in to comment.