Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Retry.php
Go to the documentation of this file.
1 <?php
7 
15 
19 class Retry extends Action
20 {
24  private $bulkManagement;
25 
29  private $notificationManagement;
30 
34  private $accessValidator;
35 
43  public function __construct(
44  Context $context,
45  BulkManagement $bulkManagement,
46  BulkNotificationManagement $notificationManagement,
47  AccessValidator $accessValidator
48  ) {
49  parent::__construct($context);
50  $this->bulkManagement = $bulkManagement;
51  $this->notificationManagement = $notificationManagement;
52  $this->accessValidator = $accessValidator;
53  }
54 
58  protected function _isAllowed()
59  {
60  return $this->_authorization->isAllowed('Magento_Logging::system_magento_logging_bulk_operations')
61  && $this->accessValidator->isAllowed($this->getRequest()->getParam('uuid'));
62  }
63 
67  public function execute()
68  {
69  $bulkUuid = $this->getRequest()->getParam('uuid');
70  $isAjax = $this->getRequest()->getParam('isAjax');
71  $operationsToRetry = (array)$this->getRequest()->getParam('operations_to_retry', []);
72  $errorCodes = [];
73  foreach ($operationsToRetry as $operationData) {
74  if (isset($operationData['error_code'])) {
75  $errorCodes[] = (int)$operationData['error_code'];
76  }
77  }
78 
79  $affectedOperations = $this->bulkManagement->retryBulk($bulkUuid, $errorCodes);
80  $this->notificationManagement->ignoreBulks([$bulkUuid]);
81  if (!$isAjax) {
82  $this->messageManager->addSuccessMessage(
83  __('%1 item(s) have been scheduled for update."', $affectedOperations)
84  );
86  $result = $this->resultRedirectFactory->create();
87  $result->setPath('bulk/index');
88  } else {
90  $result = $this->resultFactory->create(ResultFactory::TYPE_JSON);
91  $result->setHttpResponseCode(200);
92  $response = new \Magento\Framework\DataObject();
93  $response->setError(0);
94 
95  $result->setData($response);
96  }
97  return $result;
98  }
99 }
$response
Definition: 404.php:11
__()
Definition: __.php:13
__construct(Context $context, BulkManagement $bulkManagement, BulkNotificationManagement $notificationManagement, AccessValidator $accessValidator)
Definition: Retry.php:43