magento2 icon indicating copy to clipboard operation
magento2 copied to clipboard

Webapi: Configurable product can not be updated

Open pmzandbergen opened this issue 2 years ago • 6 comments

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

  • [ ] Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • [X] Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • [ ] Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • [ ] Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • [ ] Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

pmzandbergen avatar Aug 10 '22 12:08 pmzandbergen

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

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

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.


:warning: According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

: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

m2-assistant[bot] avatar Aug 10 '22 12:08 m2-assistant[bot]

@magento give me 2.4-develop instance

pmzandbergen avatar Aug 10 '22 13:08 pmzandbergen

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

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

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.

pmzandbergen avatar Aug 10 '22 13:08 pmzandbergen

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:

  • [ ] 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.

m2-assistant[bot] avatar Aug 11 '22 06:08 m2-assistant[bot]

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

github-jira-sync-bot avatar Aug 26 '22 11:08 github-jira-sync-bot

: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.

m2-assistant[bot] avatar Aug 26 '22 11:08 m2-assistant[bot]

@magento I am working on this

simsComputing avatar Sep 17 '22 14:09 simsComputing

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.

m2-assistant[bot] avatar Sep 17 '22 14:09 m2-assistant[bot]

@magento add to contributors team

simsComputing avatar Sep 17 '22 14:09 simsComputing

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

m2-assistant[bot] avatar Sep 17 '22 14:09 m2-assistant[bot]

@magento I am working on this

simsComputing avatar Sep 17 '22 14:09 simsComputing

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

pmzandbergen avatar Sep 17 '22 15:09 pmzandbergen

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

simsComputing avatar Sep 17 '22 18:09 simsComputing

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

simsComputing avatar Sep 18 '22 10:09 simsComputing