88
99namespace Magento \AsynchronousOperations \Model ;
1010
11- use Magento \Framework \ Exception \ NoSuchEntityException ;
12- use Magento \Framework \ EntityManager \ EntityManager ;
11+ use Magento \AsynchronousOperations \ Api \ BulkStatusInterface ;
12+ use Magento \AsynchronousOperations \ Api \ Data \ BulkOperationsStatusInterface ;
1313use Magento \AsynchronousOperations \Api \Data \BulkOperationsStatusInterfaceFactory as BulkStatusShortFactory ;
14+ use Magento \AsynchronousOperations \Api \Data \DetailedBulkOperationsStatusInterface ;
1415use Magento \AsynchronousOperations \Api \Data \DetailedBulkOperationsStatusInterfaceFactory as BulkStatusDetailedFactory ;
15- use Magento \AsynchronousOperations \Api \ Data \ OperationDetailsInterfaceFactory ;
16- use Magento \AsynchronousOperations \ Api \ BulkStatusInterface ;
17- use Magento \AsynchronousOperations \ Model \ ResourceModel \ Operation \ CollectionFactory ;
16+ use Magento \AsynchronousOperations \Model \ ResourceModel \ Operation \ CollectionFactory as OperationCollectionFactory ;
17+ use Magento \Framework \ EntityManager \ EntityManager ;
18+ use Magento \Framework \ Exception \ NoSuchEntityException ;
1819
1920/**
20- * Class BulkStatus
21+ * Process bulk operations status.
2122 */
2223class BulkOperationsStatus implements BulkStatusInterface
2324{
@@ -42,28 +43,26 @@ class BulkOperationsStatus implements BulkStatusInterface
4243 private $ bulkStatus ;
4344
4445 /**
45- * @var CollectionFactory
46+ * @var OperationCollectionFactory
4647 */
4748 private $ operationCollectionFactory ;
4849
4950 /**
50- * Init dependencies.
51- *
5251 * @param BulkStatus $bulkStatus
53- * @param CollectionFactory $operationCollection
52+ * @param OperationCollectionFactory $operationCollection
5453 * @param BulkStatusDetailedFactory $bulkDetailedFactory
5554 * @param BulkStatusShortFactory $bulkShortFactory
56- * @param \Magento\Framework\EntityManager\ EntityManager $entityManager
55+ * @param EntityManager $entityManager
5756 */
5857 public function __construct (
5958 BulkStatus $ bulkStatus ,
60- CollectionFactory $ operationCollection ,
59+ OperationCollectionFactory $ operationCollection ,
6160 BulkStatusDetailedFactory $ bulkDetailedFactory ,
6261 BulkStatusShortFactory $ bulkShortFactory ,
6362 EntityManager $ entityManager
6463 ) {
65- $ this ->operationCollectionFactory = $ operationCollection ;
6664 $ this ->bulkStatus = $ bulkStatus ;
65+ $ this ->operationCollectionFactory = $ operationCollection ;
6766 $ this ->bulkDetailedFactory = $ bulkDetailedFactory ;
6867 $ this ->bulkShortFactory = $ bulkShortFactory ;
6968 $ this ->entityManager = $ entityManager ;
@@ -82,7 +81,10 @@ public function getFailedOperationsByBulkId($bulkUuid, $failureType = null)
8281 */
8382 public function getOperationsCountByBulkIdAndStatus ($ bulkUuid , $ status )
8483 {
85- return $ this ->bulkStatus ->getOperationsCountByBulkIdAndStatus ($ bulkUuid , $ status );
84+ return $ this ->operationCollectionFactory ->create ()
85+ ->addFieldToFilter ('bulk_uuid ' , $ bulkUuid )
86+ ->addFieldToFilter ('status ' , $ status )
87+ ->getSize ();
8688 }
8789
8890 /**
@@ -108,7 +110,7 @@ public function getBulkDetailedStatus($bulkUuid)
108110 {
109111 $ bulkSummary = $ this ->bulkDetailedFactory ->create ();
110112
111- /** @var \Magento\AsynchronousOperations\Api\Data\ DetailedBulkOperationsStatusInterface $bulk */
113+ /** @var DetailedBulkOperationsStatusInterface $bulk */
112114 $ bulk = $ this ->entityManager ->load ($ bulkSummary , $ bulkUuid );
113115
114116 if ($ bulk ->getBulkId () === null ) {
@@ -119,7 +121,9 @@ public function getBulkDetailedStatus($bulkUuid)
119121 )
120122 );
121123 }
122- $ operations = $ this ->operationCollectionFactory ->create ()->addFieldToFilter ('bulk_uuid ' , $ bulkUuid )->getItems ();
124+ $ operations = $ this ->operationCollectionFactory ->create ()
125+ ->addFieldToFilter ('bulk_uuid ' , $ bulkUuid )
126+ ->getItems ();
123127 $ bulk ->setOperationsList ($ operations );
124128
125129 return $ bulk ;
@@ -132,7 +136,7 @@ public function getBulkShortStatus($bulkUuid)
132136 {
133137 $ bulkSummary = $ this ->bulkShortFactory ->create ();
134138
135- /** @var \Magento\AsynchronousOperations\Api\Data\ BulkOperationsStatusInterface $bulk */
139+ /** @var BulkOperationsStatusInterface $bulk */
136140 $ bulk = $ this ->entityManager ->load ($ bulkSummary , $ bulkUuid );
137141 if ($ bulk ->getBulkId () === null ) {
138142 throw new NoSuchEntityException (
@@ -142,7 +146,9 @@ public function getBulkShortStatus($bulkUuid)
142146 )
143147 );
144148 }
145- $ operations = $ this ->operationCollectionFactory ->create ()->addFieldToFilter ('bulk_uuid ' , $ bulkUuid )->getItems ();
149+ $ operations = $ this ->operationCollectionFactory ->create ()
150+ ->addFieldToFilter ('bulk_uuid ' , $ bulkUuid )
151+ ->getItems ();
146152 $ bulk ->setOperationsList ($ operations );
147153
148154 return $ bulk ;
0 commit comments