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

Add grouped product to cart #369

Open
wants to merge 5 commits into
base: 2.3-develop
from

Conversation

Projects
None yet
3 participants
@ldusan84
Copy link
Contributor

ldusan84 commented Feb 13, 2019

Description (*)

Add grouped product to cart feature:

  • Added handlers for add to cart in di.xml
  • Added grouped product handler
  • Added grouped product graphql schema

Fixed Issues (if relevant)

  1. #144: Add grouped product to Cart

Manual testing scenarios (*)

  1. Create empty cart
mutation {
  createEmptyCart
}
  1. Get cart id:
{
  "data": {
    "createEmptyCart": "cl5qYfT2q0hSdF5H9cee9JGLMDziVy2b"
  }
}
  1. Add grouped product:
mutation {
  addGroupedProductsToCart(
    input: {
      cart_id: "cl5qYfT2q0hSdF5H9cee9JGLMDziVy2b", 
      cartItems: [
        {
          data: {
            sku: "24-WG085_Group",
            grouped_products: [{
              sku: "24-WG085",
              qty: 1
            }]            
          }          
        }
      ]
    }
  ) {
    cart {
      items {
        id
      }
    }
  }
}
  1. The expected result:
{
  "data": {
    "addGroupedProductsToCart": {
      "cart": {
        "items": [
          {
            "id": "1"
          }
        ]
      }
    }
  }
}

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 on Travis CI are green)

@ldusan84 ldusan84 requested review from naydav and removed request for naydav Feb 13, 2019

{
/**
* @param CartInterface $cart
* @param ContextInterface $context

This comment has been minimized.

@TomashKhamlai

TomashKhamlai Feb 15, 2019

Collaborator

Maybe?
/**
* @param Quote $cart
* @param array $cartItemData
* @return void
*/
I hope it helps.

This comment has been minimized.

@ldusan84

ldusan84 Feb 18, 2019

Author Contributor

@TomashKhamlai yes, good spot. Thanks.

namespace Magento\QuoteGraphQl\Model\Cart;
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
use Magento\Framework\GraphQl\Query\Resolver\ContextInterface;

This comment has been minimized.

@TomashKhamlai

TomashKhamlai Feb 15, 2019

Collaborator

Shall we keep it here?
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
use Magento\Framework\GraphQl\Query\Resolver\ContextInterface;

This comment has been minimized.

@ldusan84

ldusan84 Feb 18, 2019

Author Contributor

@TomashKhamlai makes sense. Thanks.

@TomashKhamlai

This comment has been minimized.

Copy link
Collaborator

TomashKhamlai commented Feb 21, 2019

I removed the branch locally before checking this PR again. Please check the
app/code/Magento/QuoteGraphQl/Model/Cart/AddToCartHandlerInterface::execute method, I think the problem is there. If class AddProductsToCart implements AddToCartHandlerInterface then you should use Magento\Quote\Api\Data\CartInterface; as first parameter (where you pass use Magento\Quote\Model\Quote) and PHPDoc comment should also be updated.

Try

php bin/magento setup:di:compile

for more details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.