Magento2: Updating a product through the API unchecks "Use Default Value" on a bunch of attributes

Created on 22 Jan 2020  路  26Comments  路  Source: magento/magento2

When you update a product. For example adding an image using the API. Which is totally unrelated to anything else, such as editing price.

The checkbox "Use Default Value" becomes unchecked on a bunch of attributes, such as price.

This turns into a problem when you want to edit the product later, update the price, or the description etc. and nothing happens. So you have to change store view scope to that particular store, check the box "Use Default Value" and save to be able to change the price.

This should not happen in the first place.

Preconditions (*)

  1. Magento 2.3.3
  2. 2 store views

Steps to reproduce (*)

  1. Create 2 store views
  2. Add a new product with a price
  3. Change store view on the product. You can see "Use Default Value" for price is checked.
  4. Update the product using the API, for example uploading an image
  5. View the product again and change store scope
  6. Notice the "Use Default Value" on price is now unchecked (amongst other attributes)

Expected result (*)

Checkbox "Use Default Value" should remain checked until a user actually unchecks it.

Actual result (*)

Checkbox "Use Default Value" unchecks itself when you update the product using the API for all store views.

Additional info

I just re-produced it on 2.4-dev.

Seems to be a problem with scopes.

In addition to the steps above, do the following:

  1. Stores > All Stores. Click "Main Website Store" and change "Default Store View" to the second store view

image

  1. Open "Default Store View" and change to status to disabled
  2. Go into product, select scope "Default store view" (first store) Click "Use Default Value" on everything. Save.
  3. Change store scope to second store view. Click "Use Default Value" on everything. Save.
  4. Change scope to second store view again. A bunch of "Use Default Value" are unchecked.

image

CD Api Catalog Clear Description Confirmed Format is valid Ready for Work P2 ready for dev Reported on 2.3.3 Reproduced on 2.4.x S2

Most helpful comment

That solves nothing.

All 26 comments

Hi @Zyles. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • [ ] Summary of the issue
  • [ ] Information on your environment
  • [ ] Steps to reproduce
  • [ ] Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

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

For more details, please, review the Magento Contributor Assistant documentation.

@Zyles do you confirm that you were able to reproduce the issue on vanilla Magento instance following steps to reproduce?

  • [ ] yes
  • [ ] no

Hi @engcom-Bravo. 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:

  • [ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.
  • [ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • [ ] 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • [ ] 4. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and _stop verification process here_!

  • [ ] 5. Add label Issue: Confirmed once verification is complete.

  • [ ] 6. Make sure that automatic system confirms that report has been added to the backlog.

Hello @Zyles,
Thank you for your report.

Unfortunately, we are not able to reproduce this issue.
We tried to reproduce it via Swagger API, _catalogProductAttributeMediaGalleryManagementV1 POST
/V1/products/{sku}/media_
We are using the following body

{
  "entry": {

    "media_type": "image",
    "label": "string",
    "position": 0,
    "disabled": false,
    "types": [

    ],
    "file": "test.jpeg",
    "content": {
      "base64_encoded_data": "/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBw0NDQ0NDw0QDg0NDQ8NDQ4PDw8QEhAOGBEXFxURFRUYHCggGBomGxYVITEhJSkrLy4uFx8zODMsNzQtLisBCgoKDQ0ODg0NDisZHxkrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrK//AABEIAOEA4QMBIgACEQEDEQH/xAAcAAEAAwADAQEAAAAAAAAAAAAABQYHAQQIAwL/xABIEAACAgECAgUGBw0GBwAAAAAAAQIDBAUREiEGMUFRYQcTFCIycSNCVJGSk9EVFhdDUlZigYKUodLTJTNVcrHhJDVTosH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OPspS2cq14LiTXhJFXQF4830S/62pPt5qLb9/qnb07Wej2mSty8L0u7NVM4Y6yYrgVkltxb7Lbxfc2u0z1/NsEB+7bZTnOyc3OycpTnOXXKbe8pPx3Zpfkc6R8E56ZZL1bHK3E37J9dla969ZeKl3mZde3LqW3L/wAn1xr50zhbXJwsrlGdc11xmmmpL5u0D1CCJ6K65DUsKnKjspSXDdBfEuXtR93avBolgoAAAAAAAAAAAAAAAAAAAAA62oadj5UFXkU131qSmoWwjOKkk0pbPt5v5yP+9LSf8NxP3er7CZAEN96Wk/4bifu9X2D70tJ/w3E/d6vsJkAVHygdFYZunKuitRuwo8eJCCS9VR2lQl2JxSSXfGJg3Lbfw36us9Tmd5nQimjWLNUmv7PqhLOlXFcUvS09/NqC5tb+vsut7RCIvOz6tG0nTcHNxK9RyZueV6NkOKji1y4tlu4y5pycdv8APz2SRCffpp35s4H04f0SE1/Jzc/LuzLMe9StnvGPmrPg4LlCC5di2973ZHegZHye76mz7ALX9+unfmzgfTh/ROfv10782cD6cP6JU/QMj5Pd9TZ9g9AyPk931Vn2AW1dNdO/NrB+nD+iH000782sH6cP6JUlgZHye76mz7CT6O9GsnOy6cbzVtcJy3ttlXJKFS5ylu1tvtyXi0BsXk7yYZGJPJr02nTqrrXwQpafnlFcLsltCO3PeK/y+4tR88XHhTXXVXFQrqhGuuC6owS2SX6j6BQAAAAAAAAAAAAAAAAAAAAAAAAAAAABzu+8bvvOABzu+8bvvOABzu+8bnAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB//2Q==",
      "type": "image/jpeg",
      "name": "test.jpeg"
    }

  }
}

The product is updated, image added. But when we switch between Store Views, the Use Default value checkboxes are still checked. We tried to reproduce with one Website and several, the result is the same, all checkboxes are checked.
usedefaultcheckboxes

Can you please provide us with more info: the number of Websites and StoreViews, which API Client and query body you are using?

Thank you for your contribution.

Where is the text swatch?

Look at the other store views.

Oh sorry another issue.

See if the effect happens if you do this: https://github.com/magento/magento2/issues/26481

Could be related to the text swatch that unchecks the boxes.

I also found this: https://community.magento.com/t5/Magento-2-x-Technical-Issues/quot-Use-Default-Values-quot-Checkbox-Unchecked-While-Update/td-p/137217

So can be related to $Product->save(); and swatches. I assume that call is being made when you update something with the API.

Hello @Zyles

Thank you for your quick response. Can you please clarify what do you mean by "_See if the effect happens if you do this: #26481"_ ?
The issue #26481 is already Confirmed and is Ready for Work

Thank you

That issue does not mention the "unchecking of use default value" problem.

But it MAY be related to text swatch.

Please confirm by testing with a text swatch with a default value on the product.

Hello @Zyles

We have tested Updating the product with Text Swatch attribute through the API.
We have rechecked with a default _value1_, for example,
swatch_2
and with default _empty_ value.
swatch_1

Rechecked with two API requests:

  • _catalogProductRepositoryV1 PUT /V1/products/{sku}_
  • _catalogProductAttributeMediaGalleryManagementV1 POST
    /V1/products/{sku}/media_

The _Use Default Value_ checkboxes do not become unchecked on all Store Views

This issue is not reproducible on Magento 2.4-develop, so we have to close it.
Please feel free to comment, reopen or create new ticket according to the Issue reporting guidelines
if you are still facing this issue on the latest 2.4-develop branch.

Thank you for collaboration.

I just re-produced it on 2.4-dev.

Seems to be a problem with scopes.

In addition to the steps above, do the following:

  1. Stores > All Stores. Click "Main Website Store" and change "Default Store View" to the second store view

image

  1. Open "Default Store View" and change to status to disabled
  2. Go into product, select scope "Default store view" (first store) Click "Use Default Value" on everything. Save.
  3. Change store scope to second store view. Click "Use Default Value" on everything. Save.
  4. Change scope to second store view again. A bunch of "Use Default Value" are unchecked.

image

Please confirm.

Please re-open this issue.

I've the same issue on 2.3.3; after creating a product it's enough to send the empty payload {"product":{}} in PUT to /en/index.php/rest//V1/products/ in order to uncheck all the "Use Default Value" attributes having scope "website"

could you please double check?

Thanks for opening this issue!

:white_check_mark: Confirmed by @engcom-Bravo
Thank you for verifying the issue. Based on the provided information internal tickets MC-31118 were created

Issue Available: @engcom-Bravo, _You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself._

This has caused massive problems for us.

When we update our product prices using the API, every single product has unchecked the "Use default" values.

So that means everytime we edit a product, disable it etc. We have to do it on multiple storefronts because the values are no longer shared.

This is a duplicate of https://github.com/magento/magento2/issues/9186 btw
The official response from the Magento Enterprise support can be found here (more then 6 months have passed since then, it looks like nothing happened, yay!)

Good to see they are working on a 3 year old bug that affects thousands of stores... Oh wait.

indeed it's very strange; it's a very severe bug leading to data corruption. At the moment we're stuck with a quite big project due to this bug

Has anyone found a good solution/workaround?

I may have found something, which should be temporary until it's fixed (well let's be honest, might as well be a permanent "dirty fix" given the speed at which they are trying to fix this bug).

Wanted to share it because this bug is kind of a nightmare and it feels like I might not be the only one...

Have not tried it yet, but it's explained on the main issue here if you are interested: https://github.com/magento/magento2/issues/9186#issuecomment-608047932

no good solution. On my side I'm sending at every request to update a storeview the base settings of the website too. Quick and (very) dirty, but far from optimal

Hello,
was this bug fixed on M 2.3.5?
Tnx

just onep this file
/public_html/vendor/magento/module-ui/view/base/web/js/form/form.js

search 
 _.each(additional, function (value, name) {
                source.set('data.' + name, value);
            });

add code after that

// HACK for product - use default value...
                if($('input[name="product[name]"]').length){
                    console.log("admin edit ");
                    // source.set('data.use_default[name]', 1);
                    $(".admin__field-service").each(function(i, v){
                        if($(this).find("input").attr("type") == "checkbox"){
                            var name = $(this).find("input").attr("name");
                            var checked = $(this).find("input").prop("checked");
                            var value = 0;
                            if(checked){
                                value = 1;
                            }
                            source.set('data.'+name, value);
                        }
                    });
                }
            // HACK for product - use default value...

That solves nothing.

I've just had this issue.
I am creating or updating a product with "rest/all/V1/products/", everything fine until than but after that i have to make some store specific changes for a product with "rest//V1/products/sku" like price or name, the product images "loose" their roles for that store.

i have the same issue but with category api, as i havent test the product api yet

i use admin token, i have 3 store view, which is en, tc,sc

i call below request

PUT https://{my domain}/rest/{my store view code}/V1/categories/10

with this body

{ "category": { "name": "Eng name" } }

Result: include in menu, enable category, url key will uncheck usedefault

We have exactly the same problem at the moment - but we are not using the API, we used the Import functionality and now... all our products are a huge mess and when saving a field in a store view, sometimes all the translations are kicked out without noticing.
This bug is not Low Priority... This should be critical. Multistore Setup with Magento 2 is impossible with this bug.

@domi-nique I tried to resolve the issue several times, but significant resources are necessary to solve it. If it is critical for you - you can assign your resources to resolve it - at least partially.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

BenSpace48 picture BenSpace48  路  3Comments

jzalenski picture jzalenski  路  3Comments

ostmond picture ostmond  路  3Comments

kirashet666 picture kirashet666  路  3Comments

andreaskoch picture andreaskoch  路  3Comments