9
9
10
10
use Magento \Catalog \Api \Data \ProductInterface ;
11
11
use Magento \Catalog \Model \Product ;
12
- use Magento \Catalog \Model \ProductFactory ;
13
12
use Magento \ConfigurableProduct \Model \ResourceModel \Product \Type \Configurable \Product \Collection as ChildCollection ;
14
13
use Magento \ConfigurableProduct \Model \ResourceModel \Product \Type \Configurable \Product \CollectionFactory ;
15
14
use Magento \Framework \EntityManager \MetadataPool ;
16
15
use Magento \Framework \Api \SearchCriteriaBuilder ;
17
- use Magento \CatalogGraphQl \Model \Resolver \Products \DataProvider \Product as DataProvider ;
16
+ use Magento \CatalogGraphQl \Model \Resolver \Products \DataProvider \Product \ CollectionProcessorInterface ;
18
17
19
18
/**
20
19
* Collection for fetching configurable child product data.
@@ -26,21 +25,11 @@ class Collection
26
25
*/
27
26
private $ childCollectionFactory ;
28
27
29
- /**
30
- * @var ProductFactory
31
- */
32
- private $ productFactory ;
33
-
34
28
/**
35
29
* @var SearchCriteriaBuilder
36
30
*/
37
31
private $ searchCriteriaBuilder ;
38
32
39
- /**
40
- * @var DataProvider
41
- */
42
- private $ productDataProvider ;
43
-
44
33
/**
45
34
* @var MetadataPool
46
35
*/
@@ -61,25 +50,27 @@ class Collection
61
50
*/
62
51
private $ attributeCodes = [];
63
52
53
+ /**
54
+ * @var CollectionProcessorInterface
55
+ */
56
+ private $ collectionProcessor ;
57
+
64
58
/**
65
59
* @param CollectionFactory $childCollectionFactory
66
- * @param ProductFactory $productFactory
67
60
* @param SearchCriteriaBuilder $searchCriteriaBuilder
68
- * @param DataProvider $productDataProvider
69
61
* @param MetadataPool $metadataPool
62
+ * @param CollectionProcessorInterface $collectionProcessor
70
63
*/
71
64
public function __construct (
72
65
CollectionFactory $ childCollectionFactory ,
73
- ProductFactory $ productFactory ,
74
66
SearchCriteriaBuilder $ searchCriteriaBuilder ,
75
- DataProvider $ productDataProvider ,
76
- MetadataPool $ metadataPool
67
+ MetadataPool $ metadataPool ,
68
+ CollectionProcessorInterface $ collectionProcessor
77
69
) {
78
70
$ this ->childCollectionFactory = $ childCollectionFactory ;
79
- $ this ->productFactory = $ productFactory ;
80
71
$ this ->searchCriteriaBuilder = $ searchCriteriaBuilder ;
81
- $ this ->productDataProvider = $ productDataProvider ;
82
72
$ this ->metadataPool = $ metadataPool ;
73
+ $ this ->collectionProcessor = $ collectionProcessor ;
83
74
}
84
75
85
76
/**
@@ -148,7 +139,11 @@ private function fetch() : array
148
139
/** @var ChildCollection $childCollection */
149
140
$ childCollection = $ this ->childCollectionFactory ->create ();
150
141
$ childCollection ->setProductFilter ($ product );
151
- $ childCollection ->addAttributeToSelect ($ attributeData );
142
+ $ this ->collectionProcessor ->process (
143
+ $ childCollection ,
144
+ $ this ->searchCriteriaBuilder ->create (),
145
+ $ attributeData
146
+ );
152
147
153
148
/** @var Product $childProduct */
154
149
foreach ($ childCollection ->getItems () as $ childProduct ) {
0 commit comments