Skip to content

Commit f7ff71a

Browse files
Merge forwardport of #12734 to 2.3-develop branch
Applied pull request patch https://github.com/magento/magento2/pull/12734.patch (created by @dzianis-yurevich) based on commit(s): 1. e6a7a4e Fixed GitHub Issues in 2.3-develop branch: - #6916: Update Bundle Product without changes in bundle items (reported by @magecodenet)
2 parents 2c1a23f + 94a3f03 commit f7ff71a

File tree

2 files changed

+14
-2
lines changed
  • app/code/Magento/Bundle
    • Controller/Adminhtml/Product/Initialization/Helper/Plugin
    • Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/Plugin

2 files changed

+14
-2
lines changed

app/code/Magento/Bundle/Controller/Adminhtml/Product/Initialization/Helper/Plugin/Bundle.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ protected function processBundleOptionsData(\Magento\Catalog\Model\Product $prod
127127
}
128128
$options = [];
129129
foreach ($bundleOptionsData as $key => $optionData) {
130-
if ((bool)$optionData['delete']) {
130+
if (!empty($optionData['delete'])) {
131131
continue;
132132
}
133133

app/code/Magento/Bundle/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/Plugin/BundleTest.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ protected function setUp()
5757
'setOptions',
5858
'setCanSaveBundleSelections',
5959
'__wakeup',
60-
'getOptionsReadonly'
60+
'getOptionsReadonly',
61+
'getBundleOptionsData',
62+
'getExtensionAttributes',
63+
'setExtensionAttributes',
6164
];
6265
$this->productMock = $this->createPartialMock(\Magento\Catalog\Model\Product::class, $methods);
6366
$optionInterfaceFactory = $this->getMockBuilder(\Magento\Bundle\Api\Data\OptionInterfaceFactory::class)
@@ -127,6 +130,15 @@ public function testAfterInitializeIfBundleAnsCustomOptionsAndBundleSelectionsEx
127130
);
128131
$this->productMock->expects($this->once())->method('setOptions')->with(null);
129132
$this->productMock->expects($this->once())->method('setCanSaveBundleSelections')->with(true);
133+
$this->productMock->expects($this->once())->method('getBundleOptionsData')->willReturn(['option_1' => ['delete' => 1]]);
134+
$extentionAttribute = $this->getMockBuilder(\Magento\Catalog\Api\Data\ProductExtensionInterface::class)
135+
->disableOriginalConstructor()
136+
->setMethods(['setBundleProductOptions'])
137+
->getMockForAbstractClass();
138+
$extentionAttribute->expects($this->once())->method('setBundleProductOptions')->with([]);
139+
$this->productMock->expects($this->once())->method('getExtensionAttributes')->willReturn($extentionAttribute);
140+
$this->productMock->expects($this->once())->method('setExtensionAttributes')->with($extentionAttribute);
141+
130142
$this->model->afterInitialize($this->subjectMock, $this->productMock);
131143
}
132144

0 commit comments

Comments
 (0)