Skip to content

Commit 50b73a5

Browse files
ENGCOM-5570: This item has weight" switcher is not sensitive to weight changes #24013
2 parents 1abd767 + 94e7733 commit 50b73a5

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
*/
88
namespace Magento\ConfigurableProduct\Controller\Adminhtml\Product\Initialization\Helper\Plugin;
99

10+
use \Magento\Catalog\Model\Product\Edit\WeightResolver;
11+
12+
/**
13+
* Update Configurations for configurable product
14+
*/
1015
class UpdateConfigurations
1116
{
1217
/**
@@ -110,6 +115,12 @@ protected function getConfigurations()
110115
if (isset($item['qty'])) {
111116
$result[$item['id']]['quantity_and_stock_status']['qty'] = $item['qty'];
112117
}
118+
119+
// Changing product to simple on weight change
120+
if (isset($item['weight']) && $item['weight'] >= 0) {
121+
$result[$item['id']]['type_id'] = \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE;
122+
$result[$item['id']]['product_has_weight'] = WeightResolver::HAS_WEIGHT;
123+
}
113124
}
114125
}
115126
}

app/code/Magento/ConfigurableProduct/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/Plugin/UpdateConfigurationsTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,9 @@ public function testAfterInitialize()
136136
'swatch_image' => 'simple2_swatch_image',
137137
'small_image' => 'simple2_small_image',
138138
'thumbnail' => 'simple2_thumbnail',
139-
'image' => 'simple2_image'
139+
'image' => 'simple2_image',
140+
'product_has_weight' => 1,
141+
'type_id' => 'simple'
140142
],
141143
'product3' => [
142144
'quantity_and_stock_status' => ['qty' => '3']

0 commit comments

Comments
 (0)