Skip to content

Commit fe9054e

Browse files
committed
#9342: Add "selection_can_change_qty" support
1 parent 77fefd8 commit fe9054e

File tree

4 files changed

+33
-10
lines changed

4 files changed

+33
-10
lines changed

app/code/Magento/BundleImportExport/Model/Export/RowCustomizer.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,8 @@ protected function getFormattedBundleSelections($optionValues, SelectionCollecti
242242
'price' => $selection->getSelectionPriceValue(),
243243
'default' => $selection->getIsDefault(),
244244
'default_qty' => $selection->getSelectionQty(),
245-
'price_type' => $this->getPriceTypeValue($selection->getSelectionPriceType())
245+
'price_type' => $this->getPriceTypeValue($selection->getSelectionPriceType()),
246+
'can_change_qty' => $selection->getSelectionCanChangeQty(),
246247
];
247248
$bundleData .= $optionValues
248249
. ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR

app/code/Magento/BundleImportExport/Model/Import/Product/Type/Bundle.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,8 @@ protected function populateSelectionTemplate($selection, $optionId, $parentId, $
311311
? self::SELECTION_PRICE_TYPE_FIXED : self::SELECTION_PRICE_TYPE_PERCENT,
312312
'selection_price_value' => (isset($selection['price'])) ? (float)$selection['price'] : 0.0,
313313
'selection_qty' => (isset($selection['default_qty'])) ? (float)$selection['default_qty'] : 1.0,
314-
'selection_can_change_qty' => isset($selection['can_change_qty']) ? ($selection['can_change_qty'] ? 1 : 0) : 1,
314+
'selection_can_change_qty' => isset($selection['can_change_qty'])
315+
? ($selection['can_change_qty'] ? 1 : 0) : 1,
315316
];
316317
if (isset($selection['selection_id'])) {
317318
$populatedSelection['selection_id'] = $selection['selection_id'];

app/code/Magento/BundleImportExport/Test/Unit/Model/Export/Product/RowCustomizerTest.php

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,20 @@ protected function setUp()
105105
);
106106
$this->selection = $this->createPartialMock(
107107
\Magento\Catalog\Model\Product::class,
108-
['getSku', 'getSelectionPriceValue', 'getIsDefault', 'getSelectionQty', 'getSelectionPriceType']
108+
[
109+
'getSku',
110+
'getSelectionPriceValue',
111+
'getIsDefault',
112+
'getSelectionQty',
113+
'getSelectionPriceType',
114+
'getSelectionCanChangeQty'
115+
]
109116
);
110117
$this->selection->expects($this->any())->method('getSku')->willReturn(1);
111118
$this->selection->expects($this->any())->method('getSelectionPriceValue')->willReturn(1);
112119
$this->selection->expects($this->any())->method('getSelectionQty')->willReturn(1);
113120
$this->selection->expects($this->any())->method('getSelectionPriceType')->willReturn(1);
121+
$this->selection->expects($this->any())->method('getSelectionCanChangeQty')->willReturn(1);
114122
$this->selectionsCollection = $this->createPartialMock(
115123
\Magento\Bundle\Model\ResourceModel\Selection\Collection::class,
116124
['getIterator', 'addAttributeToSort']
@@ -168,6 +176,19 @@ public function testAddData()
168176
'additional_attributes' => $attributes
169177
];
170178
$preparedRow = $preparedData->addData($dataRow, 1);
179+
180+
$bundleValues = [
181+
'name=title',
182+
'type=1',
183+
'required=1',
184+
'sku=1',
185+
'price=1',
186+
'default=',
187+
'default_qty=1',
188+
'price_type=percent',
189+
'can_change_qty=1',
190+
];
191+
171192
$expected = [
172193
'sku' => 'sku1',
173194
'additional_attributes' => 'attribute=1,attribute2="Text",attribute3=One,Two,Three',
@@ -176,7 +197,7 @@ public function testAddData()
176197
'bundle_sku_type' => 'fixed',
177198
'bundle_price_view' => 'As low as',
178199
'bundle_weight_type' => 'fixed',
179-
'bundle_values' => 'name=title,type=1,required=1,sku=1,price=1,default=,default_qty=1,price_type=percent'
200+
'bundle_values' => implode(',', $bundleValues)
180201
];
181202
$this->assertEquals($expected, $preparedRow);
182203
}

dev/tests/integration/testsuite/Magento/BundleImportExport/Model/Import/Product/Type/BundleTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,15 @@ public function testBundleImport()
105105
$this->assertEquals($optionIdList[$optionSku], $productLink->getData('entity_id'));
106106
$this->assertEquals($optionSku, $productLink->getData('sku'));
107107

108-
switch ($optionKey) {
109-
case 0:
110-
$this->assertEquals(1, $productLink->getData('selection_can_change_qty'));
111-
break;
108+
switch ($optionKey + 1 + $linkKey) {
112109
case 1:
113-
$this->assertEquals(0, $productLink->getData('selection_can_change_qty'));
110+
$this->assertEquals(1, (int) $productLink->getCanChangeQuantity());
114111
break;
115112
case 2:
116-
$this->assertEquals(1, $productLink->getData('selection_can_change_qty'));
113+
$this->assertEquals(0, (int) $productLink->getCanChangeQuantity());
114+
break;
115+
case 3:
116+
$this->assertEquals(1, (int) $productLink->getCanChangeQuantity());
117117
break;
118118
}
119119
}

0 commit comments

Comments
 (0)