File tree Expand file tree Collapse file tree 3 files changed +66
-1
lines changed
app/code/Magento/CatalogGraphQl/Model/Resolver/Products/DataProvider
Product/CollectionProcessor
dev/tests/api-functional/testsuite/Magento/GraphQl/ConfigurableProduct Expand file tree Collapse file tree 3 files changed +66
-1
lines changed Original file line number Diff line number Diff line change @@ -86,6 +86,9 @@ public function getList(
86
86
$ collection ->load ();
87
87
88
88
// Methods that perform extra fetches post-load
89
+ if (in_array ('media_gallery_entries ' , $ attributes )) {
90
+ $ collection ->addMediaGalleryData ();
91
+ }
89
92
if (in_array ('options ' , $ attributes )) {
90
93
$ collection ->addOptionsToResult ();
91
94
}
Original file line number Diff line number Diff line change @@ -49,7 +49,6 @@ public function process(
49
49
$ collection ->addAttributeToSelect ($ mediaAttribute );
50
50
}
51
51
}
52
- $ collection ->addMediaGalleryData ();
53
52
}
54
53
55
54
return $ collection ;
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Copyright © Magento, Inc. All rights reserved.
4
+ * See COPYING.txt for license details.
5
+ */
6
+ declare (strict_types=1 );
7
+
8
+ namespace Magento \GraphQl \ConfigurableProduct ;
9
+
10
+ use Magento \TestFramework \TestCase \GraphQlAbstract ;
11
+
12
+ /**
13
+ * Test configurable product queries work correctly
14
+ */
15
+ class ConfigurableProductQueryTest extends GraphQlAbstract
16
+ {
17
+
18
+ /**
19
+ * @magentoApiDataFixture Magento/ConfigurableProduct/_files/product_configurable.php
20
+ */
21
+ public function testNonVisibleVariationsNotReturned ()
22
+ {
23
+ $ categoryId = '2 ' ;
24
+ $ query = <<<QUERY
25
+ {
26
+ products(filter: {category_id: {eq: " {$ categoryId }"}}) {
27
+ items {
28
+ __typename
29
+ sku
30
+ name
31
+ url_key
32
+ price {
33
+ regularPrice {
34
+ amount {
35
+ currency
36
+ value
37
+ }
38
+ }
39
+ }
40
+ media_gallery_entries {
41
+ media_type
42
+ label
43
+ position
44
+ file
45
+ id
46
+ types
47
+ }
48
+ description {
49
+ html
50
+ }
51
+ }
52
+ }
53
+ }
54
+ QUERY ;
55
+
56
+ $ result = $ this ->graphQlQuery ($ query );
57
+ $ products = $ result ['products ' ]['items ' ];
58
+ $ this ->assertCount (1 , $ products );
59
+ $ this ->assertEquals ('ConfigurableProduct ' , $ products [0 ]['__typename ' ]);
60
+ $ this ->assertEquals ('configurable ' , $ products [0 ]['sku ' ]);
61
+ $ this ->assertArrayHasKey ('media_gallery_entries ' , $ products [0 ]);
62
+ }
63
+ }
You can’t perform that action at this time.
0 commit comments