Magento2: Rest API Magento 2.4 order update overwrites existing item information

Created on 19 Apr 2019  路  14Comments  路  Source: magento/magento2

Preconditions (*)

magento 2.4-develop

Steps to reproduce (*)

  1. Place an order with a product with custom option.
  2. On the order item in the database the custom options are stored in the sales_order_item table, product_options field in the info_buyRequest as "key": "value" pair.
  3. Update the order using the Rest API (f.e. just hold order).

  4. The product_options are manipulated, omitting the custom options (they are present as options as object, but missing in the info_buy_request as "key": "value" pair.

Expected result (*)

The info_buyRequest remain as they were before the API Update
image

Actual result (*)

The info_buyRequest data are changed
image

Sales Fixed in 2.4.x Clear Description Confirmed Format is valid Ready for Work P3 Reproduced on 2.3.x Reproduced on 2.4.x S2

Most helpful comment

Same issue here. Seems like very major/important issue. It works good with Simple but not with Bundle products.

Preconditions (*)

Magento Version 2.3.1

Steps to reproduce (*)

Place an order with a bundle product with custom options
On the order item in the database the custom options are stored in the product_options column in the info_buyRequest as "key": "value" pair.
Ship the order from the admin order edit screen or when add a comment and save the order programmatically.
The product_options are manipulated, omitting the custom options and keeps some new "key": "value" pairs. Most of the `info_buy_request` "key": "value" pairs are missing.

Expected result (*)

The product_options remain as they were before the order state update

Actual result (*)

Missing custom options in the product_options column (sales_order table).

All 14 comments

Hi @aschrammel. 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-engcom-team give me 2.3-develop instance - upcoming 2.3.x release

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

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

  • [ ] yes
  • [ ] no

@magento-engcom-team It's not possible to reproduce on remote instance, as I don't have database access to this instance.

Hi @engcom-backlog-nazar. 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.3-develop branch

    Details- Add the comment @magento-engcom-team give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.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. Verify that the issue is reproducible on 2.2-develop branch.

    Details- Add the comment @magento-engcom-team give me 2.2-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x

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

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

Hi @aschrammel thank you for you report, this issue has already ben fixed in this -> commit https://github.com/magento/magento2/commit/7c6ecc33bf6d5707021548e0920650b7feec265c

Hi @engcom-backlog-nazar,

thanks for your feedback but unfortunately the fix you mentioned does not fix the problem described.
The custom options stored in the info_buyRequest as options object with it's corresponding ID but not - as it's done before the update - as textual key and value.

E.g. i have on in the the product_options field in sales_order_itemtable something like this:

{
    "info_buyRequest": {
        "uenc": "XXX",
        "product": "XXX",
        "serial_number": "XXX",
        "country": "AT",
        "max_qty": "1",
        "related_product": "",
        "qty": "1",
        "options": {
            "17": "XXX",
            "18": "AT"
        }
    },
    "options": [
        {
            "label": "Seriennummer",
            "value": "XXX",
            "print_value": "XXX",
            "option_id": "17",
            "option_type": "field",
            "option_value": "XXX",
            "custom_view": false
        },
        {
            "label": "Installationsland",
            "value": "AT",
            "print_value": "AT",
            "option_id": "18",
            "option_type": "field",
            "option_value": "AT",
            "custom_view": false
        }
    ]
}

After updating the order via the API the product_options field in sales_order_item is contains following:

{
    "info_buyRequest": {
        "qty": "1.0000",
        "options": {
            "17": "XXX",
            "18": "AT"
        }
    },
    "options": [
        {
            "label": "Seriennummer",
            "value": "XXX",
            "print_value": "XXX",
            "option_id": "17",
            "option_type": "field",
            "option_value": "XXX",
            "custom_view": false
        },
        {
            "label": "Installationsland",
            "value": "AT",
            "print_value": "AT",
            "option_id": "18",
            "option_type": "field",
            "option_value": "AT",
            "custom_view": false
        }
    ]
}

For us it is not an option to rely on the option IDs or the options array as for the same content (Serial / Installation Country) various IDs and labels in different languages exist.

So the issue in this case are the missing data in info_buyRequest:

"uenc": "XXX",
"product": "XXX",
"serial_number": "XXX",
"country": "AT",
"max_qty": "1",
"related_product": "",

After placing the order the data is stored on the item correctly - it's only missing after updating the order via API.

I hope it's more clear now.
Thank you in advance :)

Additionally maybe interesting is the fact, that this happens on virutal products!
As far as I've seen now, there's no ProductOptionProcessor for virtuals.

Hi @maheshWebkul721. 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.3-develop branch

    Details- Add the comment @magento-engcom-team give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.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. Verify that the issue is reproducible on 2.2-develop branch.

    Details- Add the comment @magento-engcom-team give me 2.2-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x

Hi @GovindaSharma. 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.3-develop branch

    Details- Add the comment @magento-engcom-team give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.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. Verify that the issue is reproducible on 2.2-develop branch.

    Details- Add the comment @magento-engcom-team give me 2.2-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x

Same issue here. Seems like very major/important issue. It works good with Simple but not with Bundle products.

Preconditions (*)

Magento Version 2.3.1

Steps to reproduce (*)

Place an order with a bundle product with custom options
On the order item in the database the custom options are stored in the product_options column in the info_buyRequest as "key": "value" pair.
Ship the order from the admin order edit screen or when add a comment and save the order programmatically.
The product_options are manipulated, omitting the custom options and keeps some new "key": "value" pairs. Most of the `info_buy_request` "key": "value" pairs are missing.

Expected result (*)

The product_options remain as they were before the order state update

Actual result (*)

Missing custom options in the product_options column (sales_order table).

Hi @engcom-Charlie. 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.3-develop branch

    Details- Add the comment @magento give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.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.

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

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

Here is a temp fix if you need to use the item saving api using a preference, if you rely on updating the product_options in the api this will not work though: https://gist.github.com/salesigniter/967f594a7ab34c6f73162e4e92fd34fb

Hi @engcom-Charlie. Thank you for working on this issue.
Looks like this issue is already verified and confirmed. But if you want to validate it one more time, please, go though the following instruction:


    1. Add/Edit Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

    1. 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_!
    1. If the issue is not relevant or is not reproducible any more, feel free to close it.

Hi @aschrammel. Thank you for your report.
The issue has been fixed in magento/magento2#28483 by @engcom-Charlie in 2.4-develop branch
Related commit(s):

The fix will be available with the upcoming 2.4.1 release.

Was this page helpful?
0 / 5 - 0 ratings