-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Fixes: Bundle product with only one product in required bundle option not being added to cart with bundle option. #38601
Conversation
Hi @bhoopatparmar. Thank you for your contribution! Add the comment under your pull request to deploy test or vanilla Magento instance:
❗ Automated tests can be triggered manually with an appropriate comment:
Allowed build names are:
You can find more information about the builds here For more details, review the Code Contributions documentation. |
@magento run all tests |
@magento create issue |
@@ -74,6 +74,12 @@ use Magento\Wishlist\Helper\Data; | |||
<?php if ($_item->isSaleable()): ?> | |||
<?php $postParams = $block->getAddToCartPostParams($_item); ?> | |||
<form data-role="tocart-form" data-product-sku="<?= $escaper->escapeHtml($_item->getSku()) ?>" action="<?= $escaper->escapeUrl($postParams['action']) ?>" method="post"> | |||
<?php $options = $block->getViewModel()->getOptionsData($_item); ?> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will be complete solution if you add the same for the pagebuilder package (in their repository https://github.com/magento/magento2-page-builder) https://github.com/magento/magento2-page-builder/blob/4a2795ea9d2dae7cec8437e5e25e78e67c1b8d90/app/code/Magento/PageBuilder/view/frontend/templates/catalog/product/widget/content/carousel.phtml#L62
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as here: https://github.com/magento/magento2-page-builder/pull/868/files#r1560503440
<?php $options = $block->getViewModel()->getOptionsData($_item); ?>
change it to
<?php if($options = $block->getViewModel()?->getOptionsData($_item)) : ?>
will prevent empty/not assigned viewModel
and ofc, close if, at the end of foreach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Bashev Thanks for your suggestion. I've updated the code as per your suggestion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine for me.
@magento run all tests |
@magento give me test instance |
Hi @engcom-Bravo. Thank you for your request. I'm working on Magento instance for you. |
Hi @engcom-Bravo, here is your Magento Instance: https://28ee115254eb32b2e9f687bedaaa2ba2.instances-prod.magento-community.engineering |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @bhoopatparmar,
Thanks for the collaboration & contribution!
❌ QA not Passed
Manual Scenario Steps
- Create a bundle product that contains one or more bundle options & each bundle option is required and must contain only one product that is default selected. (see screenshot 1)
- Create a widget with the type ‘Catalog Product List’ with a condition that includes the newly created bundle product in the widget. (see screenshot 2)
- From the front end visit the widget & try to add the bundle product from the widget product list.(see screenshot 3)
- After clicking Add to Cart observe a warning message in minicart. (see screenshot 4).
✔️ Expected result After Fix
The bundle product should be added to the cart with bundle options
❌ Actual result After Fix
Bundle Products are still not adding to the cart with the Bundle options.
Could you please let us know if we are missing anything.
Thanks.
@magento give me test instance |
Hi @engcom-Echo. Thank you for your request. I'm working on Magento instance for you. |
Hi @engcom-Echo, here is your Magento Instance: https://28ee115254eb32b2e9f687bedaaa2ba2.instances-prod.magento-community.engineering |
@magento run all tests |
@magento run all tests |
1 similar comment
@magento run all tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @bhoopatparmar,
Thanks for Contribution!!.
Could you please resolve conflicts to proceed further with the PR.
Thanks.
Hi @engcom-Bravo |
Description (*)
Adding a bundle product to the cart from the product list widget doesn’t let the product be added properly with the bundle option. The bundle product options are not added within the parent product. It shows a warning message in minicart like ‘Please specify product option(s)’. It doesn’t fail in all the cases, it only fails in a certain case where a bundle product has been created with a required bundle option & the bundle option contains only one product with the ‘is_default’ checkbox selected.
Screenshot 1:
Here you can see in the screenshot a bundle product has been created with a bundle option containing only one product in it & the option is required and the product is default select.
Screenshot 2:
After creating a bundle product, a widget has been created with a type of Catalog Product List & a condition that matches the particular bundle product.
Screenshot 3:
As we have created a widget, a bundle product is visible on the home page in the widget.
Screenshot 4:
When we click on the add-to-cart button, the product seems to be added to the cart & it doesn’t throw any error. And then if you check in the mini-cart, you will come to see a warning message like “Please specify product option(s).”
The same thing works fine on a list page, but it fails while adding a product to the cart through the widget.
Manual testing scenarios (*)
Expected result (*)
The bundle product should be added to the cart with bundle options.
Actual result (*)
The bundle product isn’t being added to the cart with bundle options.
Additional Information (*)
File1:
Magento/CatalogWidget/view/frontend/templates/product/widget/content/grid.phtml
File2:
Magento/Catalog/view/frontend/templates/product/list.phtml
If we check in the above-given list.phtml, it gets the option by using the ViewModel & which works fine on the list page. (see screenshot 5).
Screenshot 5:
In the given
grid.phtml
file it doesn’t get the options data where the add-to-cart form is rendered for the particular product (see screenshot 6). As the options are not rendered, adding that product to the cart will only add the parent bundle product to the cart without any bundle options. So, we need to implement the same thing aslist.phtml
to get the data ingrid.phtml
.Screenshot 6:
Solution (*)
We have to update the given phtml to get the bundle options in the add-to-cart form. We can get the bundle product options by using the
Magento\Catalog\ViewModel\Product\OptionsData
ViewModel. (see screenshot 7)A separate function has been created in the block file of the
grid.phtml
(Magento\CatalogWidget\Block\Product\ProductsList
) to get the ViewModel that returns the object ofMagento\Catalog\ViewModel\Product\OptionsData
.Screenshot 7:
Contribution checklist (*)
Resolved issues:
Related Pull Requests
https://github.com/magento-gl/magento2-page-builder/pull/84