13
13
use Magento \ConfigurableProduct \Model \ResourceModel \Product \Type \Configurable \Product \CollectionFactory ;
14
14
use Magento \Framework \EntityManager \MetadataPool ;
15
15
use Magento \Framework \Api \SearchCriteriaBuilder ;
16
+ use Magento \GraphQl \Model \Query \ContextInterface ;
16
17
use Magento \CatalogGraphQl \Model \Resolver \Products \DataProvider \Product \CollectionProcessorInterface ;
17
18
use Magento \CatalogGraphQl \Model \Resolver \Products \DataProvider \Product \CollectionPostProcessor ;
18
19
@@ -118,11 +119,12 @@ public function addEavAttributes(array $attributeCodes) : void
118
119
* Retrieve child products from for passed in parent id.
119
120
*
120
121
* @param int $id
122
+ * @param ContextInterface $context|null
121
123
* @return array
122
124
*/
123
- public function getChildProductsByParentId (int $ id ) : array
125
+ public function getChildProductsByParentId (int $ id, ContextInterface $ context = null ) : array
124
126
{
125
- $ childrenMap = $ this ->fetch ();
127
+ $ childrenMap = $ this ->fetch ($ context );
126
128
127
129
if (!isset ($ childrenMap [$ id ])) {
128
130
return [];
@@ -134,9 +136,10 @@ public function getChildProductsByParentId(int $id) : array
134
136
/**
135
137
* Fetch all children products from parent id's.
136
138
*
139
+ * @param ContextInterface $context|null
137
140
* @return array
138
141
*/
139
- private function fetch () : array
142
+ private function fetch (ContextInterface $ context = null ) : array
140
143
{
141
144
if (empty ($ this ->parentProducts ) || !empty ($ this ->childrenMap )) {
142
145
return $ this ->childrenMap ;
@@ -150,7 +153,8 @@ private function fetch() : array
150
153
$ this ->collectionProcessor ->process (
151
154
$ childCollection ,
152
155
$ this ->searchCriteriaBuilder ->create (),
153
- $ attributeData
156
+ $ attributeData ,
157
+ $ context
154
158
);
155
159
$ childCollection ->load ();
156
160
$ this ->collectionPostProcessor ->process ($ childCollection , $ attributeData );
0 commit comments