Skip to content

Fix for adding more then one configurable product #31654

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 24, 2021
Merged

Fix for adding more then one configurable product #31654

merged 4 commits into from
Oct 24, 2021

Conversation

nige-one
Copy link
Contributor

@nige-one nige-one commented Jan 15, 2021

Description (*)

Related Pull Requests

Fixed Issues (if relevant)

  1. Fixes Graphql - issue adding multiple configurable products to cart #30948

Manual testing scenarios (*)

  1. see Graphql - issue adding multiple configurable products to cart #30948

Questions or comments

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds are green)

@m2-assistant
Copy link

m2-assistant bot commented Jan 15, 2021

Hi @nige-one. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.4-develop instance - deploy vanilla Magento instance

❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names. Allowed build names are:

  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE,
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests
  13. Semantic Version Checker

You can find more information about the builds here

ℹ️ Please run only needed test builds instead of all when developing. Please run all test builds before sending your PR for review.

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

⚠️ According to the Magento Contribution requirements, all Pull Requests must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 You can find the schedule on the Magento Community Calendar page.

📞 The triage of Pull Requests happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket.

🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel

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

@nige-one
Copy link
Contributor Author

@magento run all tests

@nige-one
Copy link
Contributor Author

The failing Functional Tests do not seems to be related to this MR.

@m2-community-project m2-community-project bot added the Priority: P2 A defect with this priority could have functionality issues which are not to expectations. label Mar 9, 2021
@bgorski bgorski self-assigned this Mar 23, 2021
@bgorski bgorski self-requested a review March 23, 2021 21:38
Copy link
Contributor

@bgorski bgorski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nige-one thank you for your contribution! Could you cover your bugfix with an API Functional test? I think you could modify the testAddMultipleConfigurableProductToCart() method from the \Magento\GraphQl\ConfigurableProduct\AddConfigurableProductToCartTest test class by using the Magento/ConfigurableProduct/_files/configurable_products.php fixture instead of Magento/ConfigurableProduct/_files/product_configurable.php and adjusting the method body accordingly. Just be aware that we currently have a bug with running API Functional tests mentioned in #32252 - but the proposed solution mentioned there works as a workaround.

@bgorski
Copy link
Contributor

bgorski commented Mar 24, 2021

@magento run Functional Tests EE, Functional Tests CE, Functional Tests B2B

@bgorski
Copy link
Contributor

bgorski commented Mar 24, 2021

@magento run Functional Tests CE, Functional Tests B2B

@bgorski bgorski added the Auto-Tests: Not Covered Changes in Pull Request requires coverage by auto-tests label May 8, 2021
@magento-engcom-team
Copy link
Contributor

Hi @bgorski, thank you for the review.
ENGCOM-9076 has been created to process this Pull Request

@bgorski
Copy link
Contributor

bgorski commented Jul 10, 2021

@magento run all tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@engcom-Alfa
Copy link
Contributor

engcom-Alfa commented Jul 14, 2021

Hi @kassner , @orlangur
Thanks for the collaboration & contribution!

❌ QA not Passed

By adding a configurable product to the cart, getting an API response as You need to choose options for your item.

Manual Scenario Steps

  1. Used the fresh Magento instance having an sample data setup; Created a customer account in the front end.
  2. Received the customer token using a POST call rest/default/V1/integration/customer/token
  3. Checked the empty cart using GET call rest/default/V1/carts/mine
  4. Posted a simple product into the cart using POST call /rest/default/V1/carts/mine/items; Below is the payload -

{
"cartItem": {
"sku": "24-MB01",
"qty": 1,
"quote_id": "4"
}
}

  1. Posted configurable product with 2 options into the cart using POST call /rest/default/V1/carts/mine/items; Below is the payload (Used as per the RefDoc) -

{
"cartItem": {
"sku": "MH01",
"qty": 1,
"quote_id": "4",
"product_option": {
"extension_attributes": {
"configurable_item_options": [
{
"option_id": "93",
"option_value": 52
},
{
"option_id": "144",
"option_value": 172
}
]
}
},
"extension_attributes": {}
}
}

❌ Received successful response like below using POST call /rest/default/V1/carts/mine/items, but cart item is really not containing the second option with option id-144 & option-value 172

{
"item_id": 8,
"sku": "MH01-S-Gray",
"qty": 2,
"name": "Chaz Kangeroo Hoodie",
"price": 52,
"product_type": "configurable",
"quote_id": "4",
"product_option": {
"extension_attributes": {
"configurable_item_options": [
{
"option_id": "93",
"option_value": 52
},
{
"option_id": "144",
"option_value": 172
}
]
}
}
}

✔️ Expected result

  • If we GET call rest/default/V1/carts/mine; It should respond with updated cart items where both the configurable product options should be added to the cart. But, second option has not been added to the cart. Below is the cart items list response:

{
"id": 4,
"created_at": "2021-07-14 17:59:51",
"updated_at": "2021-07-15 10:37:22",
"is_active": true,
"is_virtual": false,
"items": [
{
"item_id": 5,
"sku": "24-MB01",
"qty": 1,
"name": "Joust Duffle Bag",
"price": 34,
"product_type": "simple",
"quote_id": "4"
},
{
"item_id": 6,
"sku": "MH01-XS-Gray",
"qty": 1,
"name": "Chaz Kangeroo Hoodie",
"price": 52,
"product_type": "configurable",
"quote_id": "4"
},
{
"item_id": 8,
"sku": "MH01-S-Gray",
"qty": 2,
"name": "Chaz Kangeroo Hoodie",
"price": 52,
"product_type": "configurable",
"quote_id": "4"
}
],
"items_count": 3,
"items_qty": 4,
"customer": {
"id": 2,
"group_id": 1,
"created_at": "2021-07-14 17:59:49",
"updated_at": "2021-07-14 17:59:49",
"created_in": "Default Store View",
"email": "[email protected]",
"firstname": "Manjunath",
"lastname": "ks",
"store_id": 1,
"website_id": 1,
"addresses": [],
"disable_auto_group_change": 0,
"extension_attributes": {
"is_subscribed": false
}
},
"billing_address": {
"id": 7,
"region": null,
"region_id": null,
"region_code": null,
"country_id": null,
"street": [
""
],
"telephone": null,
"postcode": null,
"city": null,
"firstname": null,
"lastname": null,
"customer_id": 2,
"email": "[email protected]",
"same_as_billing": 0,
"save_in_address_book": 0
},
"orig_order_id": 0,
"currency": {
"global_currency_code": "USD",
"base_currency_code": "USD",
"store_currency_code": "USD",
"quote_currency_code": "USD",
"store_to_base_rate": 0,
"store_to_quote_rate": 0,
"base_to_global_rate": 1,
"base_to_quote_rate": 1
},
"customer_is_guest": false,
"customer_note_notify": true,
"customer_tax_class_id": 3,
"store_id": 1,
"extension_attributes": {
"shipping_assignments": [
{
"shipping": {
"address": {
"id": 8,
"region": null,
"region_id": null,
"region_code": null,
"country_id": null,
"street": [
""
],
"telephone": null,
"postcode": null,
"city": null,
"firstname": null,
"lastname": null,
"customer_id": 2,
"email": "[email protected]",
"same_as_billing": 1,
"save_in_address_book": 0
},
"method": null
},
"items": [
{
"item_id": 5,
"sku": "24-MB01",
"qty": 1,
"name": "Joust Duffle Bag",
"price": 34,
"product_type": "simple",
"quote_id": "4"
},
{
"item_id": 6,
"sku": "MH01-XS-Gray",
"qty": 1,
"name": "Chaz Kangeroo Hoodie",
"price": 52,
"product_type": "configurable",
"quote_id": "4"
},
{
"item_id": 8,
"sku": "MH01-S-Gray",
"qty": 2,
"name": "Chaz Kangeroo Hoodie",
"price": 52,
"product_type": "configurable",
"quote_id": "4"
}
]
}
]
}
}

Note: Given option id 144 and value 172 are valid entries; cross checked with the GET call rest/default/V1/configurable-products/MH01/options/all ; below id the options response of it.

[
{
"id": 3,
"attribute_id": "93",
"label": "Color",
"position": 1,
"values": [
{
"value_index": 49
},
{
"value_index": 52
},
{
"value_index": 56
}
],
"product_id": 68
},
{
"id": 2,
"attribute_id": "144",
"label": "Size\r",
"position": 0,
"values": [
{
"value_index": 171
},
{
"value_index": 172
},
{
"value_index": 173
},
{
"value_index": 174
},
{
"value_index": 175
}
],
"product_id": 68
}
]

@bgorski
Copy link
Contributor

bgorski commented Aug 23, 2021

I believe that the "Progress: needs update" tag was left here by the bot by mistake as a result of moving the task between columns on the board. Removing it.

@bgorski
Copy link
Contributor

bgorski commented Aug 23, 2021

@engcom-Alfa hey, please check my comment above. If you did leave that tag for a reason, please add it back and let us know what changes are requested. Thanks!

@bgorski
Copy link
Contributor

bgorski commented Aug 23, 2021

I think what just happened was also not intentional. Reverting.

@engcom-Alfa
Copy link
Contributor

HI @bgorski , Thanks for all the above updates, I will re-test and update my observations here again.

@engcom-Alfa
Copy link
Contributor

✔️ QA Passed

Preconditions:

  1. Install Magento 2 fresh instance with sample data

Manual testing scenario:

  1. Follow the execution steps from Comment

  2. Validate the GraphQL response of adding multiple products into the cart.

Before: ✖️ Responding with "No Stocks" error message even after the availability.

image

After: ✔️ Multiple configurable products got added to the cart successfully.

image

The functional testing of it has been covered in automation part if the same PR, and there is no additional regression testing is required

@sidolov
Copy link
Contributor

sidolov commented Oct 8, 2021

@magento run all tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@m2-assistant
Copy link

m2-assistant bot commented Oct 24, 2021

Hi @nige-one, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

@nige-one nige-one deleted the fix-addConfigurableProductsToCart branch February 1, 2022 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auto-Tests: Covered All changes in Pull Request is covered by auto-tests Award: bug fix Component: ConfigurableProductGraphQl Partner: Brandung partners-contribution Pull Request is created by Magento Partner Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: accept Release Line: 2.4
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Graphql - issue adding multiple configurable products to cart
5 participants