20
20
use Psr \Log \LoggerInterface ;
21
21
use Magento \AsynchronousOperations \Model \ResourceModel \Operation \OperationRepository ;
22
22
use Magento \Authorization \Model \UserContextInterface ;
23
+ use Magento \Framework \Encryption \Encryptor ;
23
24
24
25
/**
25
26
* Class MassSchedule used for adding multiple entities as Operations to Bulk Management with the status tracking
@@ -63,6 +64,11 @@ class MassSchedule
63
64
*/
64
65
private $ userContext ;
65
66
67
+ /**
68
+ * @var Encryptor
69
+ */
70
+ private $ encryptor ;
71
+
66
72
/**
67
73
* Initialize dependencies.
68
74
*
@@ -73,6 +79,7 @@ class MassSchedule
73
79
* @param LoggerInterface $logger
74
80
* @param OperationRepository $operationRepository
75
81
* @param UserContextInterface $userContext
82
+ * @param Encryptor|null $encryptor
76
83
*/
77
84
public function __construct (
78
85
IdentityGeneratorInterface $ identityService ,
@@ -81,7 +88,8 @@ public function __construct(
81
88
BulkManagementInterface $ bulkManagement ,
82
89
LoggerInterface $ logger ,
83
90
OperationRepository $ operationRepository ,
84
- UserContextInterface $ userContext = null
91
+ UserContextInterface $ userContext = null ,
92
+ Encryptor $ encryptor = null
85
93
) {
86
94
$ this ->identityService = $ identityService ;
87
95
$ this ->itemStatusInterfaceFactory = $ itemStatusInterfaceFactory ;
@@ -90,6 +98,7 @@ public function __construct(
90
98
$ this ->logger = $ logger ;
91
99
$ this ->operationRepository = $ operationRepository ;
92
100
$ this ->userContext = $ userContext ?: ObjectManager::getInstance ()->get (UserContextInterface::class);
101
+ $ this ->encryptor = $ encryptor ?: ObjectManager::getInstance ()->get (Encryptor::class);
93
102
}
94
103
95
104
/**
@@ -130,9 +139,13 @@ public function publishMass($topicName, array $entitiesArray, $groupId = null, $
130
139
$ requestItem = $ this ->itemStatusInterfaceFactory ->create ();
131
140
132
141
try {
133
- $ operations [] = $ this ->operationRepository ->createByTopic ($ topicName , $ entityParams , $ groupId );
142
+ $ operation = $ this ->operationRepository ->createByTopic ($ topicName , $ entityParams , $ groupId );
143
+ $ operations [] = $ operation ;
134
144
$ requestItem ->setId ($ key );
135
145
$ requestItem ->setStatus (ItemStatusInterface::STATUS_ACCEPTED );
146
+ $ requestItem ->setDataHash (
147
+ $ this ->encryptor ->hash ($ operation ->getSerializedData (), Encryptor::HASH_VERSION_SHA256 )
148
+ );
136
149
$ requestItems [] = $ requestItem ;
137
150
} catch (\Exception $ exception ) {
138
151
$ this ->logger ->error ($ exception );
0 commit comments