diff --git a/app/code/Magento/BundleImportExport/Model/Export/RowCustomizer.php b/app/code/Magento/BundleImportExport/Model/Export/RowCustomizer.php index 9b8518a41ffff..4004a3e5f1933 100644 --- a/app/code/Magento/BundleImportExport/Model/Export/RowCustomizer.php +++ b/app/code/Magento/BundleImportExport/Model/Export/RowCustomizer.php @@ -242,7 +242,8 @@ protected function getFormattedBundleSelections($optionValues, SelectionCollecti 'price' => $selection->getSelectionPriceValue(), 'default' => $selection->getIsDefault(), 'default_qty' => $selection->getSelectionQty(), - 'price_type' => $this->getPriceTypeValue($selection->getSelectionPriceType()) + 'price_type' => $this->getPriceTypeValue($selection->getSelectionPriceType()), + 'can_change_qty' => $selection->getSelectionCanChangeQty(), ]; $bundleData .= $optionValues . ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR diff --git a/app/code/Magento/BundleImportExport/Model/Import/Product/Type/Bundle.php b/app/code/Magento/BundleImportExport/Model/Import/Product/Type/Bundle.php index bc32483b41680..8e59c866e162a 100644 --- a/app/code/Magento/BundleImportExport/Model/Import/Product/Type/Bundle.php +++ b/app/code/Magento/BundleImportExport/Model/Import/Product/Type/Bundle.php @@ -299,6 +299,7 @@ protected function populateSelectionTemplate($selection, $optionId, $parentId, $ } else { $productId = $selection['product_id']; } + $populatedSelection = [ 'selection_id' => null, 'option_id' => (int)$optionId, @@ -310,7 +311,8 @@ protected function populateSelectionTemplate($selection, $optionId, $parentId, $ ? self::SELECTION_PRICE_TYPE_FIXED : self::SELECTION_PRICE_TYPE_PERCENT, 'selection_price_value' => (isset($selection['price'])) ? (float)$selection['price'] : 0.0, 'selection_qty' => (isset($selection['default_qty'])) ? (float)$selection['default_qty'] : 1.0, - 'selection_can_change_qty' => 1, + 'selection_can_change_qty' => isset($selection['can_change_qty']) + ? ($selection['can_change_qty'] ? 1 : 0) : 1, ]; if (isset($selection['selection_id'])) { $populatedSelection['selection_id'] = $selection['selection_id']; diff --git a/app/code/Magento/BundleImportExport/Test/Unit/Model/Export/Product/RowCustomizerTest.php b/app/code/Magento/BundleImportExport/Test/Unit/Model/Export/Product/RowCustomizerTest.php index e76e9e1ba565f..849158122e8be 100644 --- a/app/code/Magento/BundleImportExport/Test/Unit/Model/Export/Product/RowCustomizerTest.php +++ b/app/code/Magento/BundleImportExport/Test/Unit/Model/Export/Product/RowCustomizerTest.php @@ -105,12 +105,20 @@ protected function setUp() ); $this->selection = $this->createPartialMock( \Magento\Catalog\Model\Product::class, - ['getSku', 'getSelectionPriceValue', 'getIsDefault', 'getSelectionQty', 'getSelectionPriceType'] + [ + 'getSku', + 'getSelectionPriceValue', + 'getIsDefault', + 'getSelectionQty', + 'getSelectionPriceType', + 'getSelectionCanChangeQty' + ] ); $this->selection->expects($this->any())->method('getSku')->willReturn(1); $this->selection->expects($this->any())->method('getSelectionPriceValue')->willReturn(1); $this->selection->expects($this->any())->method('getSelectionQty')->willReturn(1); $this->selection->expects($this->any())->method('getSelectionPriceType')->willReturn(1); + $this->selection->expects($this->any())->method('getSelectionCanChangeQty')->willReturn(1); $this->selectionsCollection = $this->createPartialMock( \Magento\Bundle\Model\ResourceModel\Selection\Collection::class, ['getIterator', 'addAttributeToSort'] @@ -168,6 +176,19 @@ public function testAddData() 'additional_attributes' => $attributes ]; $preparedRow = $preparedData->addData($dataRow, 1); + + $bundleValues = [ + 'name=title', + 'type=1', + 'required=1', + 'sku=1', + 'price=1', + 'default=', + 'default_qty=1', + 'price_type=percent', + 'can_change_qty=1', + ]; + $expected = [ 'sku' => 'sku1', 'additional_attributes' => 'attribute=1,attribute2="Text",attribute3=One,Two,Three', @@ -176,7 +197,7 @@ public function testAddData() 'bundle_sku_type' => 'fixed', 'bundle_price_view' => 'As low as', 'bundle_weight_type' => 'fixed', - 'bundle_values' => 'name=title,type=1,required=1,sku=1,price=1,default=,default_qty=1,price_type=percent' + 'bundle_values' => implode(',', $bundleValues) ]; $this->assertEquals($expected, $preparedRow); } diff --git a/dev/tests/integration/testsuite/Magento/BundleImportExport/Model/Import/Product/Type/BundleTest.php b/dev/tests/integration/testsuite/Magento/BundleImportExport/Model/Import/Product/Type/BundleTest.php index 19923daf81c88..4a3d5d2e28afe 100644 --- a/dev/tests/integration/testsuite/Magento/BundleImportExport/Model/Import/Product/Type/BundleTest.php +++ b/dev/tests/integration/testsuite/Magento/BundleImportExport/Model/Import/Product/Type/BundleTest.php @@ -104,6 +104,18 @@ public function testBundleImport() $optionSku = 'Simple ' . ($optionKey + 1 + $linkKey); $this->assertEquals($optionIdList[$optionSku], $productLink->getData('entity_id')); $this->assertEquals($optionSku, $productLink->getData('sku')); + + switch ($optionKey + 1 + $linkKey) { + case 1: + $this->assertEquals(1, (int) $productLink->getCanChangeQuantity()); + break; + case 2: + $this->assertEquals(0, (int) $productLink->getCanChangeQuantity()); + break; + case 3: + $this->assertEquals(1, (int) $productLink->getCanChangeQuantity()); + break; + } } } } diff --git a/dev/tests/integration/testsuite/Magento/BundleImportExport/Model/Import/_files/import_bundle.csv b/dev/tests/integration/testsuite/Magento/BundleImportExport/Model/Import/_files/import_bundle.csv index 43e3d04c62e61..fdb3f39327a06 100644 --- a/dev/tests/integration/testsuite/Magento/BundleImportExport/Model/Import/_files/import_bundle.csv +++ b/dev/tests/integration/testsuite/Magento/BundleImportExport/Model/Import/_files/import_bundle.csv @@ -2,4 +2,4 @@ sku,store_view_code,attribute_set_code,product_type,product_websites,name,produc Simple 1,,Default,simple,base,Simple 1,1,100,,1000,0,1,,,,, Simple 2,,Default,simple,base,Simple 2,1,200,,1000,0,1,,,,, Simple 3,,Default,simple,base,Simple 3,1,300,,1000,0,1,,,,, -Bundle 1,,Default,bundle,base,Bundle 1,1,,shipment_type=separately,0,0,1,dynamic,dynamic,Price range,dynamic,"name=Option 1,type=checkbox,required=1,sku=Simple 1,price=0.0000,default=0,default_qty=1.0000,price_type=fixed|name=Option 2,type=checkbox,required=1,sku=Simple 2,price=0.0000,default=0,default_qty=1.0000,price_type=fixed|name=Option 2,type=checkbox,required=1,sku=Simple 3,price=0.0000,default=0,default_qty=1.0000,price_type=fixed" +Bundle 1,,Default,bundle,base,Bundle 1,1,,shipment_type=separately,0,0,1,dynamic,dynamic,Price range,dynamic,"name=Option 1,type=checkbox,required=1,sku=Simple 1,price=0.0000,default=0,default_qty=1.0000,price_type=fixed,can_change_qty=1|name=Option 2,type=checkbox,required=1,sku=Simple 2,price=0.0000,default=0,default_qty=1.0000,price_type=fixed,can_change_qty=0|name=Option 2,type=checkbox,required=1,sku=Simple 3,price=0.0000,default=0,default_qty=1.0000,price_type=fixed"