File tree Expand file tree Collapse file tree 6 files changed +47
-55
lines changed
app/code/Magento/AsynchronousOperations
dev/tests/integration/testsuite/Magento/AsynchronousOperations Expand file tree Collapse file tree 6 files changed +47
-55
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 11
11
/**
12
12
* Class Operation encapsulates methods for Operation Model Object
13
13
*/
14
- class Operation extends DataObject implements OperationInterface, BulkOperationInterface
14
+ class Operation extends DataObject implements OperationInterface
15
15
{
16
16
/**
17
17
* @var OperationStatusValidator
@@ -37,15 +37,15 @@ public function __construct(
37
37
*/
38
38
public function getId ()
39
39
{
40
- return $ this ->getData (self ::OPERATION_ID );
40
+ return $ this ->getData (self ::ID );
41
41
}
42
42
43
43
/**
44
44
* @inheritDoc
45
45
*/
46
46
public function setId ($ id )
47
47
{
48
- return $ this ->setData (self ::OPERATION_ID , $ id );
48
+ return $ this ->setData (self ::ID , $ id );
49
49
}
50
50
51
51
/**
@@ -161,22 +161,6 @@ public function setErrorCode($errorCode)
161
161
return $ this ->setData (self ::ERROR_CODE , $ errorCode );
162
162
}
163
163
164
- /**
165
- * @inheritDoc
166
- */
167
- public function getOperationKey (): ?int
168
- {
169
- return $ this ->getData (self ::ID ) ? (int ) $ this ->getData (self ::ID ) : null ;
170
- }
171
-
172
- /**
173
- * @inheritDoc
174
- */
175
- public function setOperationKey (?int $ operationKey )
176
- {
177
- return $ this ->setData (self ::ID , $ operationKey );
178
- }
179
-
180
164
/**
181
165
* Retrieve existing extension attributes object.
182
166
*
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Copyright © Magento, Inc. All rights reserved.
4
+ * See COPYING.txt for license details.
5
+ */
6
+ declare (strict_types=1 );
7
+
8
+ namespace Magento \AsynchronousOperations \Plugin ;
9
+
10
+ use Magento \AsynchronousOperations \Api \Data \OperationInterface ;
11
+ use Magento \Framework \Data \Collection \AbstractDb ;
12
+
13
+ /**
14
+ * Class for bulk operation collection updates for operation key unique values
15
+ */
16
+ class CollectionUpdater
17
+ {
18
+ /**
19
+ * Adds id value in operation_key in case of bulk operation
20
+ *
21
+ * @param AbstractDb $subject
22
+ * @param $result
23
+ * @return array
24
+ * @throws \Magento\Framework\Exception\LocalizedException
25
+ */
26
+ public function afterGetData (AbstractDb $ subject , $ result )
27
+ {
28
+ if (is_array ($ result ) && !empty ($ result ) &&
29
+ $ subject ->getResource ()->getMainTable () == "magento_operation " &&
30
+ $ subject ->getResource ()->getTable ('magento_bulk ' ) == "magento_bulk "
31
+ ) {
32
+ foreach ($ result as $ key => $ row ) {
33
+ $ result [$ key ][OperationInterface::ID ] = $ row ['id ' ];
34
+ }
35
+ }
36
+
37
+ return $ result ;
38
+ }
39
+ }
Original file line number Diff line number Diff line change 116
116
<argument name =" bulkManagement" xsi : type =" object" >Magento\AsynchronousOperations\Model\VirtualType\BulkManagement</argument >
117
117
</arguments >
118
118
</type >
119
+ <type name =" Magento\Framework\Data\Collection\AbstractDb" >
120
+ <plugin name =" collection_updater" type =" Magento\AsynchronousOperations\Plugin\CollectionUpdater" />
121
+ </type >
119
122
<preference for =" Magento\AsynchronousOperations\Api\Data\AsyncResponseInterface" type =" Magento\AsynchronousOperations\Model\AsyncResponse" />
120
123
<preference for =" Magento\AsynchronousOperations\Api\Data\ItemStatusInterface" type =" Magento\AsynchronousOperations\Model\ItemStatus" />
121
124
</config >
Original file line number Diff line number Diff line change @@ -103,7 +103,7 @@ public function testExecute(): void
103
103
);
104
104
$ this ->assertEquals (1 , $ collection ->count ());
105
105
$ operation = $ collection ->getFirstItem ();
106
- $ this ->assertEquals (1 , $ operation ->getOperationKey ());
106
+ $ this ->assertEquals (1 , $ operation ->getId ());
107
107
$ this ->assertEquals (0 , $ operation ->getErrorCode ());
108
108
$ this ->assertEquals ('Unknown Error ' , $ operation ->getResultMessage ());
109
109
}
Original file line number Diff line number Diff line change @@ -61,7 +61,7 @@ public function testGetBulkStatus()
61
61
}
62
62
/** @var OperationInterface $operation */
63
63
$ operation = array_shift ($ operations );
64
- $ operationId = $ operation ->getOperationKey ();
64
+ $ operationId = $ operation ->getId ();
65
65
66
66
$ this ->assertTrue ($ this ->model ->changeOperationStatus (
67
67
'bulk-uuid-5 ' ,
You can’t perform that action at this time.
0 commit comments