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.54k stars 9.32k forks source link

Webapi: Configurable product can not be updated #35907

Closed pmzandbergen closed 2 years ago

pmzandbergen commented 2 years ago

Preconditions and environment

Magento version >= 2.4.4-p1

Steps to reproduce

  1. Create a Configurable Product with 2 simples (configurations), called option A and B.
  2. Create a Cart containing the Configurable Product using option A
  3. Update the Cart Item to use option B using the REST API without updating the quantity (PUT guest-carts/{cartId}/items/{itemId}) *
  4. The Cart Item is still using option A

* Example PUT content

{
   "cartItem":{
      "quote_id":1,
      "qty":1,
      "product_option":{
         "extension_attributes":{
            "configurable_item_options":[
               {
                  "option_id":"1",
                  "option_value":"2"
               }
            ]
         }
      }
   }
}

Expected result

The cart item is being updated

Actual result

The cart item is unaffected

Additional information

Cause The BuyRequest is being filtered on updated quantity, see commit: https://github.com/magento/magento2/commit/5478c03cfe34030ad377594c7e6398836d304477

Suggested fix Rollback this commit, the original issue should be fixed some other way.

Release note

No response

Triage and priority

m2-assistant[bot] commented 2 years ago

Hi @pmzandbergen. 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

pmzandbergen commented 2 years ago

@magento give me 2.4-develop instance

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

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

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

Hi @pmzandbergen, here is your Magento Instance: https://81894b31c95832aae4b00b54d38377ac.instances.magento-community.engineering Admin access: https://81894b31c95832aae4b00b54d38377ac.instances.magento-community.engineering/admin_476a Login: 9d2cac5c Password: 9abb4145dc08

pmzandbergen commented 2 years ago

Confirmed

Create Cart Request

`curl --location --request POST 'https://81894b31c95832aae4b00b54d38377ac.instances.magento-community.engineering/rest/default/V1/guest-carts'`

Response

"VlDQgTJURRWXekuQFBfzMp2yOTmfMjar"

Add Item Request

curl --location --request POST 'https://81894b31c95832aae4b00b54d38377ac.instances.magento-community.engineering/rest/default/V1/guest-carts/VlDQgTJURRWXekuQFBfzMp2yOTmfMjar/items' \
--header 'Content-Type: application/json' \
--data-raw '{
    "cartItem": {
        "quote_id": "IScEXP5mP7lACkEJOlfJrWgEQULSD3GP",
        "qty": "1.0",
        "sku": "MH01",
        "product_option": {
            "extension_attributes": {
                "configurable_item_options": [
                    {
                        "option_id": "93",
                        "option_value": "49"
                    },
                    {
                        "option_id": "142",
                        "option_value": "166"
                    }
                ]
            }
        }
    }
}'

Response

{
    "item_id": 13,
    "sku": "MH01-XS-Black",
    "qty": 1,
    "name": "Chaz Kangeroo Hoodie",
    "price": 52,
    "product_type": "configurable",
    "quote_id": "6",
    "product_option": {
        "extension_attributes": {
            "configurable_item_options": [
                {
                    "option_id": "93",
                    "option_value": 49
                },
                {
                    "option_id": "142",
                    "option_value": 166
                }
            ]
        }
    }
}

Update Item Request

curl --location --request PUT 'https://81894b31c95832aae4b00b54d38377ac.instances.magento-community.engineering/rest/default/V1/guest-carts/VlDQgTJURRWXekuQFBfzMp2yOTmfMjar/items/13' \
--header 'Content-Type: application/json' \
--data-raw '{
    "cartItem": {
        "item_id": 7,
        "quote_id": "8awS3tgp0SE6afe4UDpRsQQm0vfd8s7B",
        "qty": "1.0",
        "sku": "MH01",
        "product_option": {
            "extension_attributes": {
                "configurable_item_options": [
                    {
                        "option_id": "93",
                        "option_value": "49"
                    },
                    {
                        "option_id": "142",
                        "option_value": "167"
                    }
                ]
            }
        }
    }
}'

Response

{
    "item_id": 13,
    "sku": "MH01-XS-Black",
    "qty": 1,
    "name": "Chaz Kangeroo Hoodie",
    "price": 52,
    "product_type": "configurable",
    "quote_id": "6",
    "product_option": {
        "extension_attributes": {
            "configurable_item_options": [
                {
                    "option_id": "93",
                    "option_value": 49
                },
                {
                    "option_id": "142",
                    "option_value": 166
                }
            ]
        }
    }
}

The product options should have been updated at this point, but they are not. Update Item including its quantity Request

curl --location --request PUT 'https://81894b31c95832aae4b00b54d38377ac.instances.magento-community.engineering/rest/default/V1/guest-carts/VlDQgTJURRWXekuQFBfzMp2yOTmfMjar/items/13' \
--header 'Content-Type: application/json' \
--data-raw '{
    "cartItem": {
        "item_id": 7,
        "quote_id": "8awS3tgp0SE6afe4UDpRsQQm0vfd8s7B",
        "qty": "2.0",
        "sku": "MH01",
        "product_option": {
            "extension_attributes": {
                "configurable_item_options": [
                    {
                        "option_id": "93",
                        "option_value": "49"
                    },
                    {
                        "option_id": "142",
                        "option_value": "167"
                    }
                ]
            }
        }
    }
}'

Response

{
    "item_id": 15,
    "sku": "MH01-S-Black",
    "qty": 2,
    "name": "Chaz Kangeroo Hoodie",
    "price": 52,
    "product_type": "configurable",
    "quote_id": "6",
    "product_option": {
        "extension_attributes": {
            "configurable_item_options": [
                {
                    "option_id": "93",
                    "option_value": 49
                },
                {
                    "option_id": "142",
                    "option_value": 167
                }
            ]
        }
    }
}

Both quantity and options have been updated.

m2-assistant[bot] commented 2 years ago

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

github-jira-sync-bot commented 2 years ago

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

m2-assistant[bot] commented 2 years ago

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

simsComputing commented 2 years ago

@magento I am working on this

m2-assistant[bot] commented 2 years ago

Hi @simsComputing! :wave: Thank you for collaboration. Only members of Community Contributors Team are allowed to be assigned to the issue. Please use @magento add to contributors team command to join Contributors team.

simsComputing commented 2 years ago

@magento add to contributors team

m2-assistant[bot] commented 2 years ago

Hi @simsComputing! :wave: Thank you for joining. Please accept team invitation :point_right: here :point_left: and add your comment one more time.

simsComputing commented 2 years ago

@magento I am working on this

pmzandbergen commented 2 years ago

@simsComputing has already been fixed, see https://github.com/magento/magento2/pull/35908#issuecomment-1243411000

simsComputing commented 2 years ago

@pmzandbergen , issue was fixed in commit eb02e71 i think this issue can be closed as is. I don't know the procedure.

simsComputing commented 2 years ago

Wow i didn't see your previous messages. Sorry.