Skip to content

Commit b60ce79

Browse files
committed
ACP2E-1345, added default values for insert
1 parent 9c42b97 commit b60ce79

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

app/code/Magento/Bundle/Model/ResourceModel/Selection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ public function saveSelectionPrice($item)
174174
$values = [
175175
'selection_id' => $item->getSelectionId(),
176176
'website_id' => $item->getWebsiteId(),
177-
'selection_price_type' => $item->getSelectionPriceType(),
178-
'selection_price_value' => $item->getSelectionPriceValue(),
177+
'selection_price_type' => $item->getSelectionPriceType() ?? 0,
178+
'selection_price_value' => $item->getSelectionPriceValue() ?? 0,
179179
'parent_product_id' => $item->getParentProductId(),
180180
];
181181
$connection->insertOnDuplicate(

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,32 @@ public function testAddChild()
8787
$this->assertGreaterThan(0, $childId);
8888
}
8989

90+
/**
91+
* @magentoApiDataFixture Magento/Bundle/_files/product.php
92+
* @magentoApiDataFixture Magento/Catalog/_files/product_virtual.php
93+
*/
94+
public function testAddChildWithoutPriceAndPriceType()
95+
{
96+
$productSku = 'bundle-product';
97+
$children = $this->getChildren($productSku);
98+
99+
$optionId = $children[0]['option_id'];
100+
101+
$linkedProduct = [
102+
'sku' => 'virtual-product',
103+
'option_id' => $optionId,
104+
'position' => '1',
105+
'is_default' => 1,
106+
'priceType' => null,
107+
'price' => null,
108+
'qty' => 8,
109+
'can_change_quantity' => 1,
110+
];
111+
112+
$childId = $this->addChild($productSku, $optionId, $linkedProduct);
113+
$this->assertGreaterThan(0, $childId);
114+
}
115+
90116
/**
91117
* Verify empty out of stock bundle product is in stock after child has been added.
92118
*

0 commit comments

Comments
 (0)