Skip to content

Commit 5c6db27

Browse files
committed
Merge remote-tracking branch 'origin/2.3.2-develop' into 2.3.2-develop-pr52
2 parents 39ed253 + 18efe2d commit 5c6db27

File tree

3 files changed

+66
-1
lines changed

3 files changed

+66
-1
lines changed

app/code/Magento/CatalogGraphQl/Model/Resolver/Products/DataProvider/Product.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ public function getList(
8686
$collection->load();
8787

8888
// Methods that perform extra fetches post-load
89+
if (in_array('media_gallery_entries', $attributes)) {
90+
$collection->addMediaGalleryData();
91+
}
8992
if (in_array('options', $attributes)) {
9093
$collection->addOptionsToResult();
9194
}

app/code/Magento/CatalogGraphQl/Model/Resolver/Products/DataProvider/Product/CollectionProcessor/MediaGalleryProcessor.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ public function process(
4949
$collection->addAttributeToSelect($mediaAttribute);
5050
}
5151
}
52-
$collection->addMediaGalleryData();
5352
}
5453

5554
return $collection;
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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+
}

0 commit comments

Comments
 (0)