1313use Magento \ConfigurableProduct \Model \ResourceModel \Product \Type \Configurable \Product \CollectionFactory ;
1414use Magento \Framework \EntityManager \MetadataPool ;
1515use Magento \Framework \Api \SearchCriteriaBuilder ;
16+ use Magento \GraphQl \Model \Query \ContextInterface ;
1617use Magento \CatalogGraphQl \Model \Resolver \Products \DataProvider \Product \CollectionProcessorInterface ;
1718use Magento \CatalogGraphQl \Model \Resolver \Products \DataProvider \Product \CollectionPostProcessor ;
1819
@@ -118,11 +119,12 @@ public function addEavAttributes(array $attributeCodes) : void
118119 * Retrieve child products from for passed in parent id.
119120 *
120121 * @param int $id
122+ * @param ContextInterface $context|null
121123 * @return array
122124 */
123- public function getChildProductsByParentId (int $ id ) : array
125+ public function getChildProductsByParentId (int $ id, ContextInterface $ context = null ) : array
124126 {
125- $ childrenMap = $ this ->fetch ();
127+ $ childrenMap = $ this ->fetch ($ context );
126128
127129 if (!isset ($ childrenMap [$ id ])) {
128130 return [];
@@ -134,9 +136,10 @@ public function getChildProductsByParentId(int $id) : array
134136 /**
135137 * Fetch all children products from parent id's.
136138 *
139+ * @param ContextInterface $context|null
137140 * @return array
138141 */
139- private function fetch () : array
142+ private function fetch (ContextInterface $ context = null ) : array
140143 {
141144 if (empty ($ this ->parentProducts ) || !empty ($ this ->childrenMap )) {
142145 return $ this ->childrenMap ;
@@ -150,7 +153,8 @@ private function fetch() : array
150153 $ this ->collectionProcessor ->process (
151154 $ childCollection ,
152155 $ this ->searchCriteriaBuilder ->create (),
153- $ attributeData
156+ $ attributeData ,
157+ $ context
154158 );
155159 $ childCollection ->load ();
156160 $ this ->collectionPostProcessor ->process ($ childCollection , $ attributeData );
0 commit comments