Skip to content

Commit ef389cc

Browse files
ENGCOM-8131: #28431 issue fixed #28689
2 parents d5be9ed + f044ed7 commit ef389cc

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

app/code/Magento/Bundle/Model/Product/LinksList.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ public function __construct(
3939
}
4040

4141
/**
42+
* Bundle Product Items Data
43+
*
4244
* @param \Magento\Catalog\Api\Data\ProductInterface $product
4345
* @param int $optionId
4446
* @return \Magento\Bundle\Api\Data\LinkInterface[]
@@ -50,8 +52,12 @@ public function getItems(\Magento\Catalog\Api\Data\ProductInterface $product, $o
5052
$productLinks = [];
5153
/** @var \Magento\Catalog\Model\Product $selection */
5254
foreach ($selectionCollection as $selection) {
55+
$bundledProductPrice = $selection->getSelectionPriceValue();
56+
if ($bundledProductPrice <= 0) {
57+
$bundledProductPrice = $selection->getPrice();
58+
}
5359
$selectionPriceType = $product->getPriceType() ? $selection->getSelectionPriceType() : null;
54-
$selectionPrice = $product->getPriceType() ? $selection->getSelectionPriceValue() : null;
60+
$selectionPrice = $bundledProductPrice ? $bundledProductPrice : null;
5561

5662
/** @var \Magento\Bundle\Api\Data\LinkInterface $productLink */
5763
$productLink = $this->linkFactory->create();

app/code/Magento/Bundle/Test/Unit/Model/Product/LinksListTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public function testLinksList()
9191
->method('getSelectionsCollection')
9292
->with([$optionId], $this->productMock)
9393
->willReturn([$this->selectionMock]);
94-
$this->productMock->expects($this->exactly(2))->method('getPriceType')->willReturn('price_type');
94+
$this->productMock->expects($this->once())->method('getPriceType')->willReturn('price_type');
9595
$this->selectionMock->expects($this->once())
9696
->method('getSelectionPriceType')
9797
->willReturn('selection_price_type');

dev/tests/api-functional/testsuite/Magento/Bundle/Api/ProductServiceTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ public function testUpdateBundleAddSelection()
225225
public function testUpdateBundleAddAndDeleteOption()
226226
{
227227
$bundleProduct = $this->createDynamicBundleProduct();
228+
$linkedProductPrice = 20;
228229

229230
$bundleProductOptions = $this->getBundleProductOptions($bundleProduct);
230231

@@ -238,7 +239,7 @@ public function testUpdateBundleAddAndDeleteOption()
238239
[
239240
'sku' => 'simple2',
240241
'qty' => 2,
241-
"price" => 20,
242+
"price" => $linkedProductPrice,
242243
"price_type" => 1,
243244
"is_default" => false,
244245
],
@@ -256,6 +257,7 @@ public function testUpdateBundleAddAndDeleteOption()
256257
$this->assertFalse(isset($bundleOptions[1]));
257258
$this->assertEquals('simple2', $bundleOptions[0]['product_links'][0]['sku']);
258259
$this->assertEquals(2, $bundleOptions[0]['product_links'][0]['qty']);
260+
$this->assertEquals($linkedProductPrice, $bundleOptions[0]['product_links'][0]['price']);
259261
}
260262

261263
/**

0 commit comments

Comments
 (0)