Skip to content

Commit 1beed2c

Browse files
committed
Merge branch 'comm_78764_34992' of github.com:magento-gl/magento2ce into comm_78764_25677
2 parents 1379393 + 3419612 commit 1beed2c

File tree

2 files changed

+74
-1
lines changed

2 files changed

+74
-1
lines changed

app/code/Magento/BundleGraphQl/Model/Resolver/Options/Collection.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,15 @@ private function fetch() : array
112112

113113
$productTable = $optionsCollection->getTable('catalog_product_entity');
114114
$linkField = $optionsCollection->getConnection()->getAutoIncrementField($productTable);
115+
$entityIds = array_column($this->skuMap, 'entity_id');
116+
115117
$optionsCollection->getSelect()->join(
116118
['cpe' => $productTable],
117119
'cpe.' . $linkField . ' = main_table.parent_id',
118120
[]
119121
)->where(
120122
"cpe.entity_id IN (?)",
121-
$this->skuMap
123+
$entityIds
122124
);
123125
$optionsCollection->setPositionOrder();
124126

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

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,19 @@
88
namespace Magento\GraphQl\Bundle;
99

1010
use Magento\Bundle\Model\Product\OptionList;
11+
use Magento\Bundle\Test\Fixture\Option as BundleOptionFixture;
12+
use Magento\Bundle\Test\Fixture\Product as BundleProductFixture;
1113
use Magento\Catalog\Api\Data\ProductInterface;
1214
use Magento\Catalog\Api\ProductRepositoryInterface;
15+
use Magento\Catalog\Test\Fixture\Product as ProductFixture;
1316
use Magento\Framework\App\Config\ScopeConfigInterface;
17+
use Magento\TestFramework\Fixture\DataFixture;
1418
use Magento\TestFramework\ObjectManager;
1519
use Magento\TestFramework\TestCase\GraphQlAbstract;
1620
use Magento\Store\Model\StoreManagerInterface;
1721
use Magento\Catalog\Model\Product\Attribute\Source\Status as ProductStatus;
22+
use Magento\TestFramework\Fixture\DataFixtureStorage;
23+
use Magento\TestFramework\Fixture\DataFixtureStorageManager;
1824

1925
/**
2026
* Test querying Bundle products
@@ -502,4 +508,69 @@ public function testBundleProductWithDisabledProductOption()
502508
$response = $this->graphQlQuery($query);
503509
$this->assertEmpty($response['products']['items']);
504510
}
511+
512+
#[
513+
DataFixture(ProductFixture::class, ['price' => 10], 'p1'),
514+
DataFixture(ProductFixture::class, ['price' => 20], 'p2'),
515+
DataFixture(BundleOptionFixture::class, ['product_links' => ['$p1$']], 'opt1'),
516+
DataFixture(BundleOptionFixture::class, ['product_links' => ['$p2$']], 'opt2'),
517+
DataFixture(
518+
BundleProductFixture::class,
519+
['id' => 3, 'sku' => '4bundle-product','_options' => ['$opt1$', '$opt2$']],
520+
'4bundle-product'
521+
),
522+
DataFixture(
523+
BundleProductFixture::class,
524+
['id' => 4, 'sku' => '5bundle-product','_options' => ['$opt1$', '$opt2$']],
525+
'5bundle-product'
526+
),
527+
]
528+
public function testBundleProductHavingSKUAsNextBundleProductId()
529+
{
530+
531+
$productSku = '4bundle-product';
532+
$query
533+
= <<<QUERY
534+
{
535+
products(filter: {sku: {eq: "{$productSku}"}})
536+
{
537+
items{
538+
id
539+
type_id
540+
name
541+
sku
542+
... on BundleProduct {
543+
items {
544+
option_id
545+
title
546+
required
547+
type
548+
position
549+
sku
550+
options {
551+
id
552+
quantity
553+
position
554+
is_default
555+
price
556+
price_type
557+
can_change_quantity
558+
label
559+
product {
560+
id
561+
name
562+
sku
563+
type_id
564+
}
565+
}
566+
}
567+
}
568+
}
569+
}
570+
}
571+
QUERY;
572+
573+
$response = $this->graphQlQuery($query);
574+
$this->assertNotEmpty($response['products']['items']);
575+
}
505576
}

0 commit comments

Comments
 (0)