Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Magento 2.1 Multi Select Attribute doesn't save empty values #6281

Closed
Corefix opened this issue Aug 23, 2016 · 19 comments
Closed

Magento 2.1 Multi Select Attribute doesn't save empty values #6281

Corefix opened this issue Aug 23, 2016 · 19 comments
Labels
bug report Component: Catalog Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development

Comments

@Corefix
Copy link
Contributor

Corefix commented Aug 23, 2016

Preconditions

  1. Magento 2.1
  2. Chrome 52.x

Steps to reproduce

  1. Go to Magento admin
  2. Go to Products > Catalog
  3. Select a product that have a multi select attribute
  4. Find the multi select attribute and set one or more of the options on the product (so it looks like the following image).
    screen shot 2016-08-23 at 09 28 09
  5. Save the product
  6. Go back and edit the same product again.
  7. Now deselect all options in the same multi select field
  8. Save product again

Expected result

  1. The product should now have no options selected

Actual result

  1. Product have all options still selected.

It looks like the empty fields are not included in the post request, which they should, since removing values is just as important as setting them :-)

@sevos1984
Copy link
Contributor

This is a known issue, internal ticket id MAGETWO-57226. Thanks for posting

@MomotenkoNatalia MomotenkoNatalia added Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development bug report Component: Catalog labels Aug 23, 2016
@developer-lindner
Copy link

@Corefix Update to 2.1.1. and report back or close this ticket otherwise.

@sevos1984 sevos1984 removed their assignment Sep 6, 2016
@nagno
Copy link

nagno commented Oct 4, 2016

It still not works in 2.1.1. I will create a ticket on the partner portal as well. (hopefully it will get more priority)

@TClilMouse
Copy link

Still not works in 2.1.3

@nagno
Copy link

nagno commented Dec 23, 2016

@seavenger this patch works for me: #6899

@roseofgold
Copy link

patch didn't work for me on 2.1.2

@nagno
Copy link

nagno commented Jan 5, 2017

@roseofgold
are you sure you applied it correctly?
We are using it in a production system without any issues.

@roseofgold
Copy link

@nagno No I'm not sure. I just tried applying it again and now I can't use my admin :(

@nagno
Copy link

nagno commented Jan 10, 2017

@roseofgold your issue is probably not related to this patch or you have an interfering customisation.
If you check the comments on the patch, @wigman created a 2.1.3 compatible version as well.

@roseofgold
Copy link

@nagno thought you might like to know (and for posterity) that it works for me in IE11 but not in Chrome (v55). It's probably some customization that causing problems as it works differently in different browsers.

@nagno
Copy link

nagno commented May 18, 2017

@roseofgold It is not working for us in any browser (even in a Vanilla Magento environment). It is still not working in 2.1.5.

Progress so far: we got one not working patch from the support team and another one, which was breaking the attribute set change functionality (you wasn't able to select an attribute set for new products as well).

@roseofgold
Copy link

@nagno Updating to 2.1.6 broke it all browsers and all environments. I believe this issue should not be closed.

@nkajic
Copy link
Member

nkajic commented May 26, 2017

Seems like duplicate of #6253 #7687 #4545
and that this is fixed by
https://github.com/nagno/magento2/commit/b380502570b92449326ab6ed50e6ce0359287240

@hoektoe
Copy link

hoektoe commented Jun 27, 2017

Still experiencing this issue in 2.1.4

@magento-engcom-team magento-engcom-team added Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development bug report Component: Catalog Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed labels Sep 11, 2017
@magento-engcom-team magento-engcom-team added the Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed label Oct 9, 2017
@magento-engcom-team
Copy link
Contributor

@Corefix, thank you for your report.
We were not able to reproduce this issue by following the steps you provided. If you'd like to update it, please reopen the issue.
We tested the issue on 2.3.0-dev, 2.2.0, 2.1.9

@magento-engcom-team magento-engcom-team added the Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch label Oct 9, 2017
@nagno
Copy link

nagno commented Oct 9, 2017

Of course you are not able to reproduce it, because it was fixed in 2.1.8. (See changelog for 2.1.8)
I did report it in October 2016 via the partner portal and after 2 not working patches Magento finally fixed it. It took about 9 months to provide it even with "priority" partner portal support...

@WilliamChongSDG
Copy link

This issue still persist in Magento ver. 2.2.2

@A-1A
Copy link

A-1A commented Jun 19, 2018

I Found Solution after R&D On Magento database.
Login In your phpmyadmin
Go to your website database
Open "eav_attribute" table
Find Your multiselect "attribute_id"
Edit Row
If "backend_model" Column blank then paste this Magento\Eav\Model\Entity\Attribute\Backend\ArrayBackend
And Also Please check this
https://magento.stackexchange.com/questions/224621/warning-array-filter-expects-parameter-1-to-be-array/230444#230444

@yohanespradono
Copy link

yohanespradono commented Sep 10, 2021

this happens in our v2.1.9 intermittently eventhough the attributes have Magento\Eav\Model\Entity\Attribute\Backend\ArrayBackend in its "backend_model" column.

When saving a product, some attributes have ->getAttributeSetInfo() returns null and some others return an empty array. This causes \Magento\Eav\Model\Entity\Attribute\AbstractAttribute::isInSet($setId) to return different values regarding whether getAttributeSetInfo is null or an empty array.

And later it causes function in \Magento\Eav\Model\Entity\AbstractEntity::_isApplicableAttribute() to return differently for each attribute. then it causes the foreach in \Magento\Eav\Model\Entity\AbstractEntity::walkAttributes to skip calling call_user_func_array on some attributes when those attributes have getAttributeSetInfo return empty array.

I am proposing this patch

in function \Magento\Framework\DataObject::__call
replace

            case 'has':
                $key = $this->_underscore(substr($method, 3));
                return isset($this->_data[$key]);

with

            case 'has':
                $key = $this->_underscore(substr($method, 3));
                return isset($this->_data[$key]) and !empty($this->_data[$key]);

or

in function \Magento\Eav\Model\Entity\Attribute\Set::addSetInfo($entityType, array $attributes, $setId = null)
replace

                    if (!is_array($attributeSetInfo)) {
                        $attributeSetInfo = [];
                    }

with

                    if (!is_array($attributeSetInfo)) {
                        $attributeSetInfo = null;
                    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Component: Catalog Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development
Projects
None yet
Development

No branches or pull requests