magento2: Unable to unselect all multiselect values
Magento version: 2.1.2
It is not possible to unselect and save all multiselect attribute values for a product.
After the save completes the state of the product attribute before the product was saved is unchanged.
It seems the problem is that the JS does not submit multiselect form elements with no selected values, at least on the server side completely unselected multiselect attribtues are not part of the $_POST['product'] array.
The exact same issue existed for years on M1 but was finally fixed there. It seems like this issue was introduced again for M2.
Preconditions
None special.
Steps to reproduce
- Create a custom multiselect attribute. Ot just install the sample data (e.g. the issue can be reproduced using the
features_bagorstrap_bagsattributes). - Open the product in the admin interface.
- Select one or more values of the multiselect attribtue.
- Save
- Unselect all values of the multiselect attribute
- Save again
Expected result
The product attribute should have no value for the product.
Actual result
The previously selected product attributes still are selected.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 10
- Comments: 35 (14 by maintainers)
Commits related to this issue
- MAGETWO-54733: Unable to save product with all unchecked values for multiple select attribute #7687 — committed to magento/magento2 by VladimirZaets 7 years ago
- MAGETWO-54733: Unable to save product with all unchecked values for multiple select attribute #7687 — committed to magento/magento2 by VladimirZaets 7 years ago
- MAGETWO-54733: Unable to save product with all unchecked values for multiple select attribute #7687 — committed to magento/magento2 by VladimirZaets 7 years ago
- MAGETWO-54733: Unable to save product with all unchecked values for multiple select attribute #7687 — committed to magento/magento2 by VladimirZaets 7 years ago
- MAGETWO-54733: Unable to save product with all unchecked values for multiple select attribute #7687 — committed to magento/magento2 by VladimirZaets 7 years ago
- MAGETWO-54733: Unable to save product with all unchecked values for multiple select attribute #7687 — committed to magento/magento2 by VladimirZaets 7 years ago
- MAGETWO-54733: Unable to save product with all unchecked values for multiple select attribute #7687 — committed to magento/magento2 by VladimirZaets 7 years ago
- MAGETWO-54733: Unable to save product with all unchecked values for multiple select attribute #7687 — committed to magento/magento2 by VladimirZaets 7 years ago
- MAGETWO-54733: Unable to save product with all unchecked values for multiple select attribute #7687 — committed to magento/magento2 by VladimirZaets 7 years ago
- MAGETWO-54733: Unable to save product with all unchecked values for multiple select attribute #7687 - Fix JS unit test. — committed to magento/magento2 by VladimirZaets 7 years ago
- Merge pull request #786 from magento-south/BUGS Bugs - MAGETWO-63022 [2.2] SCD does not work when multiple languages are specified. - MAGETWO-62276 'State/Province' isn't changed to input after sel... — committed to magento/magento2 by VladimirZaets 7 years ago
- MAGETWO-57607: [Backport] - Unable to save product with all unchecked values for multiple select attribute - for 2.1 #7687 — committed to magento/magento2 by OlgaVasyltsun 7 years ago
- MAGETWO-57607: [Backport] - Unable to save product with all unchecked values for multiple select attribute - for 2.1 #7687 — committed to magento/magento2 by OlgaVasyltsun 7 years ago
This issue still persist in Magento ver. 2.2.2
Still this issue also persist at magento 2.2.4 .
Have done with Vinai describe scenario and same issue is happening
@Vinai ,Is this issue resolved at your end?
@magento/community-engineering-team ,Can you please check this issue again
I had the same issue because of multiselect having an empty value (ie. equal to ‘’ or 0 or null) :
Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper\AttributeFilter prepare your attributes before saving it.
When a posted value is equal to empty string (‘’) it will compare it to the product value before saving. The issue is that Magento cast both values in boolean. And when the previously selected product value was set to 0 (like “NOT LOGGED IN” in our example) it compares an empty string casted in boolean (= false) with a 0 casted in boolean (= false too) so the value is simply unset … so the attribute isn’t saved and there is no error.
In our specific case, we fixed it using a plugin to restore the value after the prepareProductAttributes function has been called.
I hope it will help.
Still present in Magento ver. 2.2.3
I’d like to know how to get this fixed. It’s driving me nuts. (Tested on both 2.1.2 and 2.1.6)