9
9
10
10
use Magento \Catalog \Model \Category ;
11
11
use Magento \Catalog \Model \Product \Visibility ;
12
- use Magento \CatalogGraphQl \Model \Resolver \Products \DataProvider \Product \CollectionProcessor \ StockProcessor ;
12
+ use Magento \CatalogGraphQl \Model \Resolver \Products \DataProvider \Product \CompositeCollectionProcessor ;
13
13
use Magento \Framework \Api \SearchCriteriaInterface ;
14
14
use Magento \Framework \GraphQl \Exception \GraphQlInputException ;
15
15
use Magento \Framework \GraphQl \Schema \Type \ResolveInfo ;
16
16
use Magento \Framework \GraphQl \Config \Element \Field ;
17
17
use Magento \Framework \GraphQl \Query \ResolverInterface ;
18
18
19
+
19
20
/**
20
21
* Retrieves products count for a category
21
22
*/
@@ -27,9 +28,9 @@ class ProductsCount implements ResolverInterface
27
28
private $ catalogProductVisibility ;
28
29
29
30
/**
30
- * @var StockProcessor
31
+ * @var CompositeCollectionProcessor
31
32
*/
32
- private $ stockProcessor ;
33
+ private $ collectionProcessor ;
33
34
34
35
/**
35
36
* @var SearchCriteriaInterface
@@ -39,16 +40,16 @@ class ProductsCount implements ResolverInterface
39
40
/**
40
41
* @param Visibility $catalogProductVisibility
41
42
* @param SearchCriteriaInterface $searchCriteria
42
- * @param StockProcessor $stockProcessor
43
+ * @param CompositeCollectionProcessor $collectionProcessor
43
44
*/
44
45
public function __construct (
45
46
Visibility $ catalogProductVisibility ,
46
47
SearchCriteriaInterface $ searchCriteria ,
47
- StockProcessor $ stockProcessor
48
+ CompositeCollectionProcessor $ collectionProcessor
48
49
) {
49
50
$ this ->catalogProductVisibility = $ catalogProductVisibility ;
50
51
$ this ->searchCriteria = $ searchCriteria ;
51
- $ this ->stockProcessor = $ stockProcessor ;
52
+ $ this ->collectionProcessor = $ collectionProcessor ;
52
53
}
53
54
54
55
/**
@@ -63,8 +64,14 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value
63
64
$ category = $ value ['model ' ];
64
65
$ productsCollection = $ category ->getProductCollection ();
65
66
$ productsCollection ->setVisibility ($ this ->catalogProductVisibility ->getVisibleInSiteIds ());
66
- $ productsCollection = $ this ->stockProcessor ->process ($ productsCollection , $ this ->searchCriteria , []);
67
+ $ productsCollection = $ this ->collectionProcessor ->process (
68
+ $ productsCollection ,
69
+ $ this ->searchCriteria ,
70
+ [],
71
+ $ context
72
+ );
73
+ $ size = $ productsCollection ->getSize ();
67
74
68
- return $ productsCollection -> getSize () ;
75
+ return $ size ;
69
76
}
70
77
}
0 commit comments