magento2 icon indicating copy to clipboard operation
magento2 copied to clipboard

Default value for non required Drop Down product attribute

Open endergreen opened this issue 10 years ago • 23 comments

When creating a new Drop Down Product attribute that is not required, the first option added has the "Is Default" radio button selected. If the attribute is set to not be required, the radio button shouldn't automatically be set for any option either when first creating the attribute or later when coming back to edit it.

The attribute is being used in an attribute set where the particular attribute doesn't apply to a couple of products, though the other attributes in the set do. Because of "Is Default" being set automatically, all products using that attribute set end up having a value even if it doesn't apply.

endergreen avatar Feb 25 '16 12:02 endergreen

Hi,

Thank you for reporting the issue. Internal ticket MAGETWO-49780 is created for this issue.

In your case I think it's possible to add a new option 'None' and set it as default. Will it work for you?

Thanks, Kateryna.

katmoon avatar Feb 25 '16 15:02 katmoon

It is something we had talked about when finding this issue but it is causing additional work arounds that we have to do that we wouldn't if no value was there.

endergreen avatar Feb 26 '16 01:02 endergreen

@katmoon solution You proposed sounds more like workaround not a proper fix

jsakars avatar Feb 26 '16 14:02 jsakars

@werdlv You are right. It is a workaround.

katmoon avatar Feb 29 '16 05:02 katmoon

For a workaround you can use the multi-select. It comes in to your product unselected by default.

sameasterling avatar Apr 06 '16 19:04 sameasterling

The workaround of using multi-select does work. However, with a lot of options, the multi-select workaround makes for a potentially very long open list and ton of scrolling. The other problem is that if there is a fix down the road for drop down, you can not change the attribute from multi-select to drop down, so would cause a ton of work to set everything up again.

Alternatively, you can set the dropdown in the SQL database to "null" under the eav attribute. However, this also has some issues in that any time you make a change to an attribute, it resets the default and you need to again go to the SQL database to set to null set again. In addition, if a dropdown attribute is set in a product, and you want to later set it to the null set, you can not, you are forced to choose something.

I am in the process of setting up 7500+ skus, so want to know recommendation:

  1. Set all the attributes to multi-select and have very long lists of attribute options and making any fix by magento in the future not viable.
  2. Set all the attributes to drop down, use the null setting, and then wait for the fix from Magento.

Please advise - thanks!

jonsaf avatar Apr 27 '16 15:04 jonsaf

As a fix, in file vendor/magento/module-catalog/view/adminhtml/web/js/options.js or app/code/Magento/Catalog/view/adminhtml/web/js/options.js go to lines 45 - 47 and comment them out:

//   if (!this.totalItems) {
//     data.checked = 'checked';
//   }

Check if pub/static/adminhtml/Magento/backend/en_US/Magento_Catalog/js/options.js (and the same file in other language sub folders in pub/static/adminhtml/Magento/backend/) reflects that change.

You may need to remove the already set default values from the database. To do that, run SELECT * FROM eav_attribute WHERE default_value IS NOT NULL AND frontend_input != 'boolean'; to get possible affected attributes. Let's say you found that IDs 90 and 211 should be changed so that the have no default value anymore; run this query: UPDATE eav_attribute SET default_value = NULL WHERE attribute_id IN (90,211);

For visual- and text-swatches you can do the same, the files are: vendor/magento/module-swatches/view/adminhtml/web/js/visual.js or app/code/Magento/Swatches/view/adminhtml/web/js/visual.js and vendor/magento/module-swatches/view/adminhtml/web/js/text.js or app/code/Magento/Swatches/view/adminhtml/web/js/text.js

bh-ref avatar Apr 28 '16 14:04 bh-ref

Any updates on this issue? The workaround of using multi-select doesn't work for me.

shayanhusaini avatar May 03 '16 07:05 shayanhusaini

the same problem applies to text- and visual-swatches, too

bh-ref avatar May 04 '16 13:05 bh-ref

Am waiting for a fix for this issue too. Thanks

atIOCrON avatar Jun 15 '16 14:06 atIOCrON

I think this problem is fixed in Magento 2.1.0-rc2

bh-ref avatar Jun 16 '16 09:06 bh-ref

The issue should be fixed by another internal ticket MAGETWO-50123 in the next release.

katmoon avatar Jun 16 '16 11:06 katmoon

As far as I can see it's fixed in Magento 2.1, correct?

bh-ref avatar Jun 27 '16 11:06 bh-ref

Any updates on this?

As far as we are using Magento 2.1 and it is not working I think here is a lack of releasing the patch?

Nilson89 avatar Aug 02 '16 11:08 Nilson89

MAGETWO-50123 is going to be fixed in 2.2 and 2.1.x versions.

katmoon avatar Aug 15 '16 07:08 katmoon

Can you confirm this was fixed as part of 2.1.1 as I can't find any notification on this within the patch notes for 2.1.1?

jh-tom avatar Sep 14 '16 11:09 jh-tom

Am waiting for a fix on this too.

shires-boy avatar Sep 19 '16 12:09 shires-boy

Still have this issue in Magento CE ver. 2.1.2. Any news on when this might go live?

measureddesigns avatar Oct 21 '16 13:10 measureddesigns

Hi @jh-tom @measureddesigns will be fixed in internal ticket MAGETWO-57024 for 2.1 version

vzabaznov avatar Oct 25 '16 13:10 vzabaznov

This issue has been fixed in 2.2.0, and will be delivered to 2.1.x soon.

elenleonova avatar Dec 15 '16 01:12 elenleonova