Skip to content
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

Allow customer to specify associated product qtys when adding grouped product to cart via RESTful API #27845

Conversation

shawnabramson
Copy link

@shawnabramson shawnabramson commented Apr 13, 2020

Description (*)

This PR addresses the issue described here: magento/magento2#26909
Currently, when adding a grouped product to cart via RESTful API, there is no way to way to specify the quantities for the individual associated products. Additionally, there is no supporting documentation for adding a grouped product to the cart in the docs

Related Pull Requests

Fixed Issues (if relevant)

  1. Add grouped product with individual quantity to cart using rest api #26909: Add grouped product with individual quantity to cart using rest api

Manual testing scenarios (*)

These steps assume Magento sample data is installed. Otherwise, update the body of the calls to match your database.

  1. Generate a customer token by sending a post request to the rest/V1/integration/customer/token endpoint with a body of:
    { "username": "roni_cost@example.com", "password": "roni_cost3@example.com" }

  2. Create an empty cart by sending a post request to the rest/V1/carts/mine endpoint. The bearer token should be the token returned by step 1 and the body should be empty.

  3. Add a grouped product to cart by sending a post request to the rest/V1/carts/mine/items endpoint with a body of:
    The quote_id parameter in the body should be the quote ID returned by step 2. The bearer token should be the token returned by step 1.

{ "cartItem": { "sku": "gr", "qty": 1, "quote_id": "5", "product_option": { "extension_attributes": { "grouped_options": [ { "id": 2, "qty": 3}, { "id": 3, "qty": 2} ] } } } }

  1. Get the cart contents by sending a get request to the rest/V1/carts/mine endpoint. The bearer token should be the token returned by step 1 and the body should be empty.

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)

…ctOptionInterface to allow user to send associated product quantities when adding to cart via REST API

Added a 'grouped' cartItemProcessors to the Magento\Quote\Model\Quote\Item\Repository to reformat the super_group extension attribute into a format that is compatible with buy request
@m2-assistant
Copy link

m2-assistant bot commented Apr 13, 2020

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

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

@m2-assistant
Copy link

m2-assistant bot commented Apr 13, 2020

Hi @shawnabramson, 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.

@shawnabramson shawnabramson reopened this Apr 13, 2020
@shawnabramson shawnabramson marked this pull request as ready for review April 13, 2020 16:22
@shawnabramson
Copy link
Author

Is it normal that the "database compare" check run for 4.5hours and its still not finished?

@shawnabramson
Copy link
Author

@bgorski The checks are still running like 10 hours later. Is this typical?

@shawnabramson
Copy link
Author

This PR is ready for review, not sure why its failing unit tests

@sidolov sidolov added Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Severity: S2 Major restrictions or short-term circumventions are required until a fix is available. labels Aug 17, 2020
@sidolov sidolov self-assigned this Aug 25, 2020
@magento-engcom-team
Copy link
Contributor

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

@engcom-Alfa
Copy link
Contributor

✔️ QA Passed

Manual testing scenario:

  1. Generate a customer token by sending a post request to the rest/V1/integration/customer/token endpoint with a body of:
    { "username": "test@example.com", "password": "r123123qQ" }

Screenshot from 2020-12-04 10-05-16

  1. Create an empty cart by sending a post request to the rest/V1/carts/mine endpoint. The bearer token should be the token returned by step 1 and the body should be empty.

Screenshot from 2020-12-04 10-05-47

  1. Add a grouped product to cart by sending a post request to the rest/V1/carts/mine/items endpoint with a body of:
    The quote_id parameter in the body should be the quote ID returned by step 2. The bearer token should be the token returned by step 1.
    Screenshot from 2020-12-04 10-08-25

Before: ❌ We got an error: Property "SuperGroup" ...

Screenshot from 2020-11-27 10-45-45
Screenshot from 2020-11-27 10-46-14

After: ✔️ Grouped product with individual quantities was successfully added to cart

Screenshot from 2020-12-04 10-08-36
2020-12-04_10-22

Also, checked the situation when the required parameters are not defined.

Actual Result: ✔️ The correct message is shown

Screenshot from 2020-12-04 10-08-56

@m2-assistant
Copy link

m2-assistant bot commented Dec 10, 2020

Hi @shawnabramson, 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.

This pull request was closed.
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: special achievement Award: test coverage Component: GroupedProduct Partner: MRM Commerce 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 QA: Added to Regression Scope Scenario was analysed and added to Regression Testing Scope Release Line: 2.4 Severity: S2 Major restrictions or short-term circumventions are required until a fix is available.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add grouped product with individual quantity to cart using rest api
8 participants