Magento2: [Grouped product] Can麓t add simple products to cart if one other is out of stock

Created on 12 Apr 2019  路  22Comments  路  Source: magento/magento2

Preconditions (*)

  1. magento 2.2-develop
  2. php 7.1

Steps to reproduce (*)

  • enable the option allow to show products without stock
  • grouped product with more sub items
  • at least one sub items have to be without stock (quantity=0)
  • navigate to the PDS of the grouped product
  • add at least on item of any available sub item
  • if you add the item to the cart the message "Please specify the quantity of product(s)." apears

Expected result (*)

  1. the simple products are added to the cart

Actual result (*)

  1. the message "Please specify the quantity of product(s)." appears
  2. it麓s not possible to add a simple product, if one other simple product within the grouped product is out of stock
GroupedProduct imagine2019 Fixed in 2.4.x Clear Description Confirmed Format is valid Ready for Work Reproduced on 2.3.x

Most helpful comment

Hi @nickpiro,
we have a fix as Patch for 2.2.8 currently it is not possible to fix this without breaking the Backward compatiblty. Maybee we will find way but I must ask the Team,

Index: project/src/vendor/magento/module-grouped-product/Model/Product/Type/Grouped.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- vendor/magento/module-grouped-product/Model/Product/Type/Grouped.php
+++ vendor/magento/module-grouped-product/Model/Product/Type/Grouped.php
@@ -338,9 +338,6 @@
         }
         foreach ($associatedProducts as $subProduct) {
             if (!isset($productsInfo[$subProduct->getId()])) {
-                if ($isStrictProcessMode && !$subProduct->getQty()) {
-                    return __('Please specify the quantity of product(s).')->render();
-                }
                 $productsInfo[$subProduct->getId()] = $subProduct->isSalable() ? (float)$subProduct->getQty() : 0;
             }
         }

All 22 comments

Hi @hamplr. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

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

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento-engcom-team give me 2.3-develop instance - upcoming 2.3.x release

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

@hamplr do you confirm that you was able to reproduce the issue on vanilla Magento instance following steps to reproduce?

  • [x] yes
  • [ ] no

Hi @larsroettig. 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:

  • [x] 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.
  • [x] 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.3-develop branch

    Details- Add the comment @magento-engcom-team give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.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. Verify that the issue is reproducible on 2.2-develop branch.

    Details- Add the comment @magento-engcom-team give me 2.2-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x

  • [ ] 6. Add label Issue: Confirmed once verification is complete.

  • [ ] 7. Make sure that automatic system confirms that report has been added to the backlog.

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

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

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

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

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

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

Having the same issue in 2.2.8

Hi @nickpiro,
we have a fix as Patch for 2.2.8 currently it is not possible to fix this without breaking the Backward compatiblty. Maybee we will find way but I must ask the Team,

Index: project/src/vendor/magento/module-grouped-product/Model/Product/Type/Grouped.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- vendor/magento/module-grouped-product/Model/Product/Type/Grouped.php
+++ vendor/magento/module-grouped-product/Model/Product/Type/Grouped.php
@@ -338,9 +338,6 @@
         }
         foreach ($associatedProducts as $subProduct) {
             if (!isset($productsInfo[$subProduct->getId()])) {
-                if ($isStrictProcessMode && !$subProduct->getQty()) {
-                    return __('Please specify the quantity of product(s).')->render();
-                }
                 $productsInfo[$subProduct->getId()] = $subProduct->isSalable() ? (float)$subProduct->getQty() : 0;
             }
         }

I have the same problem here in 2.2.8
Any solution?
This is a blocking issue!

@larsroettig there is a commit for this patch?

No, there麓s currently no commit for this patch, but we have the patch in use in our project to solve the problem.

Hi @mallikaverma. 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.3-develop branch

    Details- Add the comment @magento-engcom-team give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.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. Verify that the issue is reproducible on 2.2-develop branch.

    Details- Add the comment @magento-engcom-team give me 2.2-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x


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

I am working on it

imagine2019

The fix from @larsroettig works for me, i created a preference for that class and then overrode the getProductInfo method:

In your module di.xml:

<preference for="Magento\GroupedProduct\Model\Product\Type\Grouped" type="Vendor\Module\Model\Grouped"/>

New class Vendor\Module\Model\Grouped:

protected function getProductInfo(\Magento\Framework\DataObject $buyRequest, $product, $isStrictProcessMode)
{
    $productsInfo = $buyRequest->getSuperGroup() ?: [];
    $associatedProducts = $this->getAssociatedProducts($product);

    if (!is_array($productsInfo)) {
        return __('Please specify the quantity of product(s).')->render();
    }
    foreach ($associatedProducts as $subProduct) {
        if (!isset($productsInfo[$subProduct->getId()])) {

            // if ($isStrictProcessMode && !$subProduct->getQty()) {
            //     return __('Please specify the quantity of product(s).')->render();
            // }

            $productsInfo[$subProduct->getId()] = $subProduct->isSalable() ? (float)$subProduct->getQty() : 0;
        }
    }

    return $productsInfo;
}

`

@joekersh preference is not the best way to solve this issue patching is a better way yesterday @mallikaverma creating a pr this look backwards compatible.

Hi @dmytro-ch. 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:

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

  • [x] 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • [x] 4. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.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. Verify that the issue is reproducible on 2.2-develop branch.

    Details- Add the comment @magento give me 2.2-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x

  • [x] 6. Add label Issue: Confirmed once verification is complete.

  • [x] 7. Make sure that automatic system confirms that report has been added to the backlog.

:white_check_mark: Confirmed by @dmytro-ch
Thank you for verifying the issue. Based on the provided information internal tickets MAGETWO-99841 were created

Issue Available: @dmytro-ch, _You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself._

I can confirm that @larsroettig 's solution is working. Thanks !

Hi @hamplr. Thank you for your report.
The issue has been fixed in magento/magento2#24955 by @gihovani in 2.4-develop branch
Related commit(s):

The fix will be available with the upcoming 2.4.0 release.

Was this page helpful?
0 / 5 - 0 ratings