Skip to content

Commit 8f65a14

Browse files
committed
ACP2E-1315: [GraphQL] Any child products of bundle product are not returned in GraphQL response
1 parent 73da5ab commit 8f65a14

File tree

2 files changed

+14
-18
lines changed

2 files changed

+14
-18
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace Magento\CatalogGraphQl\Model\Resolver\Products\DataProvider;
99

10+
use Magento\Catalog\Api\Data\ProductInterface;
1011
use Magento\Catalog\Model\Product\Visibility;
1112
use Magento\CatalogGraphQl\Model\Resolver\Products\DataProvider\Product\CollectionPostProcessor;
1213
use Magento\Framework\Api\SearchCriteriaInterface;
@@ -93,7 +94,7 @@ public function getList(
9394
$visibilityIds = $isSearch
9495
? $this->visibility->getVisibleInSearchIds()
9596
: $this->visibility->getVisibleInCatalogIds();
96-
$collection->setVisibility($visibilityIds);
97+
$collection->addAttributeToFilter(ProductInterface::VISIBILITY, $visibilityIds);
9798
}
9899

99100
$collection->load();

dev/tests/api-functional/testsuite/Magento/GraphQl/Bundle/BundleProductViewTest.php

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ public function testBundleProductWithNotVisibleChildren()
212212
}
213213
$this->assertBundleBaseFields($bundleProduct, $response['products']['items'][0]);
214214

215-
$this->assertBundleProductOptions($bundleProduct, $response['products']['items'][0], false);
215+
$this->assertBundleProductOptions($bundleProduct, $response['products']['items'][0]);
216216
$this->assertNotEmpty(
217217
$response['products']['items'][0]['items'],
218218
"Precondition failed: 'items' must not be empty"
@@ -242,9 +242,8 @@ private function assertBundleBaseFields($product, $actualResponse)
242242
/**
243243
* @param ProductInterface $product
244244
* @param array $actualResponse
245-
* @param bool $isChildVisible
246245
*/
247-
private function assertBundleProductOptions($product, $actualResponse, $isChildVisible = true)
246+
private function assertBundleProductOptions($product, $actualResponse)
248247
{
249248
$this->assertNotEmpty(
250249
$actualResponse['items'],
@@ -284,22 +283,18 @@ private function assertBundleProductOptions($product, $actualResponse, $isChildV
284283
]
285284
);
286285
$this->assertEquals(
287-
$isChildVisible ? $childProduct->getName() : null,
286+
$childProduct->getName(),
288287
$actualResponse['items'][0]['options'][0]['label']
289288
);
290-
if ($isChildVisible) {
291-
$this->assertResponseFields(
292-
$actualResponse['items'][0]['options'][0]['product'],
293-
[
294-
'id' => $childProduct->getId(),
295-
'name' => $childProduct->getName(),
296-
'type_id' => $childProduct->getTypeId(),
297-
'sku' => $childProduct->getSku()
298-
]
299-
);
300-
} else {
301-
$this->assertNull($actualResponse['items'][0]['options'][0]['product']);
302-
}
289+
$this->assertResponseFields(
290+
$actualResponse['items'][0]['options'][0]['product'],
291+
[
292+
'id' => $childProduct->getId(),
293+
'name' => $childProduct->getName(),
294+
'type_id' => $childProduct->getTypeId(),
295+
'sku' => $childProduct->getSku()
296+
]
297+
);
303298
}
304299

305300
/**

0 commit comments

Comments
 (0)