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

Minimum Qty Allowed in Shopping Cart not working on related product #19566

Merged
merged 4 commits into from
Feb 18, 2019
Merged

Minimum Qty Allowed in Shopping Cart not working on related product #19566

merged 4 commits into from
Feb 18, 2019

Conversation

mageprince
Copy link
Contributor

Description (*)

Solve Minimum Qty Allowed in Shopping Cart not working on related products

Manual testing scenarios (*)

  1. Let's take two simple products Product A and Product B
  2. Set Minimum Qty Allowed in Shopping Cart = 10 in Product A from
    Advanced Inventor->Minimum Qty Allowed in Shopping Cart
  3. Assign Product A as a related product in Product B
  4. Open PDP page of Product B
  5. Check Product A checkbox from Related Products block on PDP
  6. Add to cart Product B

Expected result (*)

Add to cart Product A with Qty = 10

Actual result (*)

  1. Add only 1 qty of Product A to the cart
  2. Showing error "We don't have as many of some products as you want."

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)

@magento-engcom-team
Copy link
Contributor

Hi @mageprince. 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-engcom-team give me test instance - deploy test instance based on PR changes
  • @magento-engcom-team give me 2.3-develop instance - deploy vanilla Magento instance

For more details, please, review the Magento Contributor Assistant documentation

@mageprince
Copy link
Contributor Author

@magento-engcom-team give me 2.3-develop instance

@magento-engcom-team
Copy link
Contributor

Hi @mageprince. Thank you for your request. I'm working on Magento 2.3-develop instance for you

@magento-engcom-team
Copy link
Contributor

Hi @mageprince, here is your Magento instance.
Admin access: https://i-19566-2-3-develop.instances.magento-community.engineering/admin
Login: admin Password: 123123q
Instance will be terminated in up to 3 hours.

@mageprince
Copy link
Contributor Author

@magento-engcom-team Issue reproduced in the test instance

@sivaschenko sivaschenko self-assigned this Dec 5, 2018
$stockItem = $this->stockRegistry->getStockItem($productId, $product->getStore()->getWebsiteId());
$minimumQty = $stockItem->getMinSaleQty();
if ($minimumQty && $minimumQty > 0) {
$request = $minimumQty;
Copy link
Contributor

Choose a reason for hiding this comment

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

Complex logic related to inventory must not be added in Checkout module. We can have much more checks than MinSaleQty.

Copy link
Contributor Author

@mageprince mageprince Dec 5, 2018

Choose a reason for hiding this comment

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

@orlangur Are you check the addProduct() function of \Magento\Checkout\Model\Cart It also check the MinSaleQty with same logic. I took the reference from there. You can check here: Cart.php

Copy link
Contributor

Choose a reason for hiding this comment

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

@mageprince does not look good as well, it should be better implemented as a plugin, probably legacy code.

Why do we need to duplicate this logic out of addProduct method?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we misunderstood functions between addProduct() of \Magento\Quote\Model\Quote and addProduct() of \Magento\Checkout\Model\Cart.

addProduct() of \Magento\Checkout\Model\Cart check the minimumQty of product to addtocart
While addProductsByIds() of \Magento\Checkout\Model\Cart not check the minimumQty but it must required to solve this issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@orlangur any update for this issue?

Copy link
Member

Choose a reason for hiding this comment

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

@mageprince considering there is very similar check in Cart.php I think it's better at least to move this check to private method and reuse in both functions. I think @orlangur would like this check to be moved to CatalogInventory module

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@orlangur @sivaschenko
I updated the pull request as per your suggestion.
Please review it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@orlangur @sivaschenko any update on this pull request.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@orlangur can you please review the changes.

@magento-engcom-team magento-engcom-team added this to the Release: 2.3.1 milestone Jan 17, 2019
@magento-engcom-team
Copy link
Contributor

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

@magento-engcom-team
Copy link
Contributor

@mageprince thank you for contributing. Please accept Community Contributors team invitation here to gain extended permissions for this repository.

@mageprince mageprince dismissed orlangur’s stale review January 28, 2019 05:48

No response from long time

@okorshenko okorshenko removed this from the Release: 2.3.1 milestone Jan 28, 2019
@magento-engcom-team magento-engcom-team merged commit a2f9965 into magento:2.3-develop Feb 18, 2019
@ghost
Copy link

ghost commented Feb 18, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants