-
Notifications
You must be signed in to change notification settings - Fork 63
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 #868
Conversation
@magento run all test |
Failed to run the builds. Please try to re-run them later. |
@magento run all tests |
@@ -61,6 +61,12 @@ use Magento\Framework\App\Action\Action; | |||
<?php if ($_item->isSaleable()): ?> | |||
<?php $postParams = $block->getAddToCartPostParams($_item); ?> | |||
<form data-role="tocart-form" data-product-sku="<?= $block->escapeHtml($_item->getSku()) ?>" action="<?= $block->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.
My suggestion is to change it on this way, if($options = $block->getViewModel()?->getOptionsData($_item)) :
to prevent nullable (not defined) viewModel.
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.
@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://6b32d64bd6d52d2142ba67dc9522350b.instances-prod.magento-community.engineering |
@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.
Hello @bhoopatparmar,
Thanks for the collaboration!
The changes look good to me, but please look into the failed tests. It seems they are failing due to PR changes.
Thanks
@magento give me test instance |
Hi @bhoopatparmar. Thank you for your request. I'm working on Magento instance for you. |
Hi @bhoopatparmar, unfortunately there is no ability to deploy Magento instance at the moment. Please try again later. |
@magento give me test instance |
Hi @bhoopatparmar. Thank you for your request. I'm working on Magento instance for you. |
Hi @bhoopatparmar, unfortunately there is no ability to deploy Magento instance at the moment. Please try again later. |
@magento give me test instance |
Hi @bhoopatparmar. Thank you for your request. I'm working on Magento instance for you. |
Hi @bhoopatparmar, unfortunately there is no ability to deploy Magento instance at the moment. Please try again later. |
@magento run all test |
Pull Requests are not mergeable to the mainline. Please merge the latest mainlines to your Pull Requests and restart the builds. |
@magento give me test instance |
Hi @bhoopatparmar. Thank you for your request. I'm working on Magento instance for you. |
Hi @bhoopatparmar, unfortunately there is no ability to deploy Magento instance at the moment. Please try again later. |
Hello @bhoopatparmar, Please resolve the conflicts first, then run tests on the PR. Thanks |
@magento give me test instance |
Hi @bhoopatparmar. Thank you for your request. I'm working on Magento instance for you. |
Hi @bhoopatparmar, unfortunately there is no ability to deploy Magento instance at the moment. Please try again later. |
Hi @engcom-Hotel Thank you! |
@magento give me test instance |
Hi @bhoopatparmar. Thank you for your request. I'm working on Magento instance for you. |
Hi @bhoopatparmar, unfortunately there is no ability to deploy Magento instance at the moment. Please try again later. |
Hi @engcom-Hotel Hence, closing this PR. |
Description (*)
Adding a bundle product to the cart from the product carousel/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 product carousel has been added to the home page content by using a page-builder that includes the particular bundle product.
Screenshot 3:
As we have created a product carousel, a bundle product is visible on the home page in the product slider.
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 see a warning message like “Please specify product option(s).”
Related Pull Requests
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 (*)
File:
Magento/PageBuilder/view/frontend/templates/catalog/product/widget/content/carousel.phtml
In the given
carousel.phtml
file it doesn’t get the options data where the add-to-cart form is rendered for the particular product (see screenshot 5). 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.Screenshot 5:
Solution (*)
We have to update the given
carousel.phtml
to get the bundle options in the add-to-cart form. We can get the bundle product options by using theMagento\Catalog\ViewModel\Product\OptionsData
ViewModel. (see screenshot 6)A separate function has been created in the block file of the
carousel.phtml
(Magento\CatalogWidget\Block\Product\ProductsList
) to get the ViewModel that returns the object ofMagento\Catalog\ViewModel\Product\OptionsData
. Refer the mentioned related PR.Screenshot 7:
The same issue happens with the product grid as well in the product slider added by page builder. That can be solved by this PR:
Checklist
Resolved issues: