Skip to content

Commit f606c8f

Browse files
authored
Unselect multiselect on product edit view
Fix for issue magento#8577 : magento#8577 Preconditions Install Magento 2 Create a product with a multiselect attribute AND selected values. Save It Steps to reproduce Unselect ALL values Save product again Expected result All values should be unselected. Actual result Previous values are still selected.
1 parent 4148ee1 commit f606c8f

File tree

1 file changed

+5
-0
lines changed
  • app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization

1 file changed

+5
-0
lines changed

app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,11 @@ public function initializeFromData(\Magento\Catalog\Model\Product $product, arra
142142
$dateFieldFilters = [];
143143
$attributes = $product->getAttributes();
144144
foreach ($attributes as $attrKey => $attribute) {
145+
if ($attribute->getFrontendInput() == 'multiselect') {
146+
if (empty($productData[$attrKey])) {
147+
$productData[$attrKey] = '';
148+
}
149+
}
145150
if ($attribute->getBackend()->getType() == 'datetime') {
146151
if (array_key_exists($attrKey, $productData) && $productData[$attrKey] != '') {
147152
$dateFieldFilters[$attrKey] = $this->getDateTimeFilter();

0 commit comments

Comments
 (0)