|
10 | 10 | */
|
11 | 11 | class Plugin
|
12 | 12 | {
|
| 13 | + public const MESSAGES_LIMIT = 5; |
13 | 14 | /**
|
14 | 15 | * @var \Magento\AdminNotification\Model\System\MessageFactory
|
15 | 16 | */
|
@@ -95,27 +96,31 @@ public function afterToArray(
|
95 | 96 | $this->bulkNotificationManagement->getAcknowledgedBulksByUser($userId)
|
96 | 97 | );
|
97 | 98 | $bulkMessages = [];
|
| 99 | + $messagesCount = 0; |
98 | 100 | foreach ($userBulks as $bulk) {
|
99 | 101 | $bulkUuid = $bulk->getBulkId();
|
100 | 102 | 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++; |
106 | 123 | }
|
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 |
| - ]; |
119 | 124 | $bulkMessages[] = $this->messageFactory->create($data)->toArray();
|
120 | 125 | }
|
121 | 126 | }
|
|
0 commit comments