Skip to content

Commit 6ad2195

Browse files
author
Anna Bukatar
committed
ACP2E-1969: Incorrect behavior for system messages when trying to delete bulk product using REST API
1 parent d9d3d9b commit 6ad2195

File tree

1 file changed

+22
-17
lines changed
  • app/code/Magento/AsynchronousOperations/Model/ResourceModel/System/Message/Collection/Synchronized

1 file changed

+22
-17
lines changed

app/code/Magento/AsynchronousOperations/Model/ResourceModel/System/Message/Collection/Synchronized/Plugin.php

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111
class Plugin
1212
{
13+
public const MESSAGES_LIMIT = 5;
1314
/**
1415
* @var \Magento\AdminNotification\Model\System\MessageFactory
1516
*/
@@ -95,27 +96,31 @@ public function afterToArray(
9596
$this->bulkNotificationManagement->getAcknowledgedBulksByUser($userId)
9697
);
9798
$bulkMessages = [];
99+
$messagesCount = 0;
98100
foreach ($userBulks as $bulk) {
99101
$bulkUuid = $bulk->getBulkId();
100102
if (!in_array($bulkUuid, $acknowledgedBulks)) {
101-
$details = $this->operationDetails->getDetails($bulkUuid);
102-
$text = $this->getText($details);
103-
$bulkStatus = $this->statusMapper->operationStatusToBulkSummaryStatus($bulk->getStatus());
104-
if ($bulkStatus === \Magento\Framework\Bulk\BulkSummaryInterface::IN_PROGRESS) {
105-
$text = __('%1 item(s) are currently being updated.', $details['operations_total']) . $text;
103+
if ($messagesCount < self::MESSAGES_LIMIT) {
104+
$details = $this->operationDetails->getDetails($bulkUuid);
105+
$text = $this->getText($details);
106+
$bulkStatus = $this->statusMapper->operationStatusToBulkSummaryStatus($bulk->getStatus());
107+
if ($bulkStatus === \Magento\Framework\Bulk\BulkSummaryInterface::IN_PROGRESS) {
108+
$text = __('%1 item(s) are currently being updated.', $details['operations_total']) . $text;
109+
}
110+
$data = [
111+
'data' => [
112+
'text' => __('Task "%1": ', $bulk->getDescription()) . $text,
113+
'severity' => \Magento\Framework\Notification\MessageInterface::SEVERITY_MAJOR,
114+
// md5() here is not for cryptographic use.
115+
// phpcs:ignore Magento2.Security.InsecureFunction
116+
'identity' => md5('bulk' . $bulkUuid),
117+
'uuid' => $bulkUuid,
118+
'status' => $bulkStatus,
119+
'created_at' => $bulk->getStartTime()
120+
]
121+
];
122+
$messagesCount++;
106123
}
107-
$data = [
108-
'data' => [
109-
'text' => __('Task "%1": ', $bulk->getDescription()) . $text,
110-
'severity' => \Magento\Framework\Notification\MessageInterface::SEVERITY_MAJOR,
111-
// md5() here is not for cryptographic use.
112-
// phpcs:ignore Magento2.Security.InsecureFunction
113-
'identity' => md5('bulk' . $bulkUuid),
114-
'uuid' => $bulkUuid,
115-
'status' => $bulkStatus,
116-
'created_at' => $bulk->getStartTime()
117-
]
118-
];
119124
$bulkMessages[] = $this->messageFactory->create($data)->toArray();
120125
}
121126
}

0 commit comments

Comments
 (0)