magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.56k stars 9.32k forks source link

Unable to save "Use Default" value for product attribute which has default value #35096

Closed kimurabanyan closed 1 year ago

kimurabanyan commented 2 years ago

 

ISSUE:

Use Default Value checkbox not checked and value not showing for product attribute

STEPS TO REPLICATE:

  1. Create a product attribute with a backend type of varchar, text or datetime and set default value at "Advanced Attribute Properties > Default Value", and add that attribute to any attribute set.
  2. Create a product of attribute set with attribute created in Step1
  3. Uncheck the "Use Default Value" checkbox for that attribute in the Store View scope and save
  4. Check the "Use Default Value" checkbox for that attribute in the Store View scope and save

ACTUAL RESULTS:

Checkbox not checked

EXPECTED RESULTS:

The "Use Default Value" checkbox for that attribute is checked in the Store View scope

 

 

m2-assistant[bot] commented 2 years ago

Hi @kimurabanyan. Thank you for your report. To speed up processing of this issue, make sure that you provided the following information:

Make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, review the Magento Contributor Assistant documentation.

Add a comment to assign the issue: @magento I am working on this

To learn more about issue processing workflow, refer to the Code Contributions.


:clock10: You can find the schedule on the Magento Community Calendar page.

:telephone_receiver: The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

:pencil2: Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

kimurabanyan commented 2 years ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 2 years ago

Hi @kimurabanyan. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 2 years ago

Hi @kimurabanyan, here is your Magento Instance: https://bca016973b0baca0f71c0f68a1856eda.instances.magento-community.engineering Admin access: https://bca016973b0baca0f71c0f68a1856eda.instances.magento-community.engineering/admin_de08 Login: 62865682 Password: 9577e569b258

kimurabanyan commented 2 years ago

Reproduced in 2.4-develop instance

Step1 attribute

result of Step4 save-product

m2-assistant[bot] commented 2 years ago

Hi @engcom-Hotel. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

engcom-Hotel commented 2 years ago

Hi @kimurabanyan,

Thank you for reporting the issue.

We have verified the issue on Magento 2.4-develop branch however the issue is not reproducible for us.

Steps performed: 1:Install a clean version of Magento version 2.4-develop 2:Create a product attribute with a backend type of varchar, text, or DateTime and set default value at "Advanced Attribute Properties > Default Value", and add that attribute to any attribute set. 3:Create a product of attribute set with attribute created in Step 2. 4:.Uncheck the "Use Default" checkbox for that attribute in the Store View scope and save as shown in the screenshot Screenshot from 2022-02-14 14-16-01

5: Check the "Use Default" checkbox for that attribute in the Store View scope and save

Screenshot from 2022-02-14 14-17-39

Result: The "Use Default" checkbox for that attribute is checked in the Store View scope Please let us know in case we are missing anything with exact reproducible steps, will retry with that scenario.

Thanks

kimurabanyan commented 2 years ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 2 years ago

Hi @kimurabanyan. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 2 years ago

Hi @kimurabanyan, here is your Magento Instance: https://bca016973b0baca0f71c0f68a1856eda.instances.magento-community.engineering Admin access: https://bca016973b0baca0f71c0f68a1856eda.instances.magento-community.engineering/admin_65a0 Login: 15707ab4 Password: 7c775d119790

kimurabanyan commented 2 years ago

Hi @engcom-Hotel

Thank you for confirming.

I confirmed that it would be reproduced again. Is your procedure missing the following step?

set default value at "Advanced Attribute Properties > Default Value",

As you can see in the red frame in the image below, this problem only occurs with attributes that have "Default Value". Perhaps you checked without setting the "Default Value".

default-value

Using the above attribute, the problem was reproduced as shown in the image below.

result

Please confirm again.

Thanks.

engcom-Delta commented 2 years ago

Hi @kimurabanyan,

Thank you for reporting the issue.

We have verified the issue on Magento 2.4-develop branch however the issue is reproducible

Steps performed: 1:Install a clean version of Magento version 2.4-develop 2:Create a product attribute with a backend type of varchar, text, or DateTime and set default value at "Advanced Attribute Properties > Default Value", and add that attribute to any attribute set. 3:Create a product of attribute set with attribute created in Step 2. 4:.Uncheck the "Use Default" checkbox for that attribute in the Store View scope and save as shown in the screenshot

350961

5: Check the "Use Default" checkbox for that attribute in the Store View scope and save 350962

Result: The "Use Default" checkbox for that attribute is not checked as shown in screenshot 350963 Based on the above observation, confirming the issue.

Thanks!

github-jira-sync-bot commented 2 years ago

:white_check_mark: Jira issue https://jira.corp.magento.com/browse/AC-2444 is successfully created for this GitHub issue.

m2-assistant[bot] commented 2 years ago

:white_check_mark: Confirmed by @engcom-Delta. Thank you for verifying the issue.
Issue Available: @engcom-Delta, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

engcom-Hotel commented 2 years ago

@engcom-Delta Please check the impact of the checkbox. This will help us in setting the priority.

Thanks

m2-assistant[bot] commented 2 years ago

Hi @engcom-Delta. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

engcom-Delta commented 2 years ago

Hi @kimurabanyan, Based on above description confirming the issue. We have verified the issue on Magento 2.4-develop branch however the issue is reproducible and so marking the issue confirmed. https://github.com/magento/magento2/issues/35096#issuecomment-1046939040

github-jira-sync-bot commented 2 years ago

:x: Cannot export the issue. This GitHub issue is already linked to Jira issue(s): https://jira.corp.magento.com/browse/AC-2444

asannikov commented 1 year ago

The cause of this is thought to be the following line. If the attribute has a default value, "false" is not set and the store view record is not deleted. https://github.com/magento/magento2/blob/2.4.3-p1/app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper/AttributeFilter.php#L83

it works on 2.4.5. I compared this file to 2.4.2 where i can reproduce this issue and i see only one difference in this file:

// M2.4.5
    private function isAttributeShouldNotBeUpdated(Product $product, array $useDefaults, $attribute, $value): bool
    {
        $considerUseDefaultsAttribute = !isset($useDefaults[$attribute]) || $useDefaults[$attribute] === '1';

        return ($value === '' && $considerUseDefaultsAttribute && ($product->getData($attribute) === null));
    }

// 2.4.2
    private function isAttributeShouldNotBeUpdated(Product $product, array $useDefaults, $attribute, $value): bool
    {
        $considerUseDefaultsAttribute = !isset($useDefaults[$attribute]) || $useDefaults[$attribute] === '1';

        return ($value === '' && $considerUseDefaultsAttribute && !$product->getData($attribute));
    }

i tried to apply this change to 2.4.2 and it did not help

VincentMarmiesse commented 1 year ago

I have the same issue on a Magento 2.4.5-p1, it seems to be related to this line.

There is a confusion between the attribute's default value, and the checkbox "Use default value" which refers to the "All store views" scope.

arnobsh commented 1 year ago

The internal team is working on this issue. Thanks

dragonfly4 commented 10 months ago

We are still seeing this issue on 2.4.6-p3

Has anyone found a patch or fix for this please?

spraxis commented 9 months ago

@dragonfly4 the fix is to create a patch to change this line: vendor/magento/module-customer-custom-attributes/Plugin/Catalog/UpdateMultiselectAttributes.php:32, from == null to === null Hope it helps.

aaievolisonco commented 6 months ago

We are still seeing this issue on 2.4.6-p4

engcom-Delta commented 6 months ago

Hello,

We have Verified the issue in Magento 2.4 dev instance and the issue is not reproducible.

Steps to reproduce:

1.Create a product attribute with a backend type of varchar, text or datetime and set default value at "Advanced Attribute Properties > Default Value", and add that attribute to any attribute set. 2.Create a product of attribute set with attribute created in Step1 3.Uncheck the "Use Default Value" checkbox for that attribute in the Store View scope and save 4.Check the "Use Default Value" checkbox for that attribute in the Store View scope and save

ACTUAL RESULTS:

The "Use Default Value" checkbox for that attribute is checked in the Store View scope

EXPECTED RESULTS:

The "Use Default Value" checkbox for that attribute is checked in the Store View scope

Please refer the evidence video attached.

https://github.com/magento/magento2/assets/51681379/3ad6d077-a9f9-4fc5-9bc1-a3a7458bc5a3

TheBadong commented 5 months ago

Hello @engcom-Delta, could you please check again with a multiselect attribute with a default value? We are still seeing this on 2.4.6-p3.

Seems to me the attribute data is not correctly emptied when send to the save controller. Here I ticked the "use default", but I am still receiving the attribute value in \Magento\CustomerCustomAttributes\Plugin\Catalog\UpdateMultiselectAttributes::afterInitializeFromData.

image
helloeverything commented 5 months ago

We are still seeing this issue on 2.4.6-p5. Can we get a quality patch to fix the === in \Magento\CustomerCustomAttributes\Plugin\Catalog\UpdateMultiselectAttributes::afterInitializeFromData ?

frostitution commented 5 months ago

We are having the same issue except we are NOT using a Default Value for our MultiSelect attribute. 2.4.6-p5

Cannot check "Use Default Value" and have it save correctly. Attribute remains unchecked

engcom-Delta commented 5 months ago

Hi @helloeverything and @frostitution ,

We have Verified the issue in Magento 2.4.6-p5 instance and the issue is reproducible.

Steps to reproduce:

1.Create a product attribute with a backend type of varchar, text or datetime and set default value at "Advanced Attribute Properties > Default Value", and add that attribute to any attribute set. 2.Create a product of attribute set with attribute created in Step1 3.Uncheck the "Use Default Value" checkbox for that attribute in the Store View scope and save 4.Check the "Use Default Value" checkbox for that attribute in the Store View scope and save

ACTUAL RESULTS:

The "Use Default Value" checkbox for that attribute is unchecked in the Store View scope

EXPECTED RESULTS:

The "Use Default Value" checkbox for that attribute is checked in the Store View scope

https://github.com/magento/magento2/assets/51681379/268aad09-2519-4a04-989c-a5f1b8afb39a

frostitution commented 5 months ago

Other things I noticed:

@spraxis This fix works, but does this have any possible effects on other things?