magento2
magento2 copied to clipboard
[Issue] Fixes: Bundle product with only one product in required bundle option not being added to cart with bundle option.
This issue is automatically created based on existing pull request: magento/magento2#38601: Fixes: Bundle product with only one product in required bundle option not being added to cart with bundle option.
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 (*)
- 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 (*)
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 as list.phtml to get the data in grid.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 of Magento\Catalog\ViewModel\Product\OptionsData.
Screenshot 7:
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)
- [ ] README.md files for modified modules are updated and included in the pull request if any README.md predefined sections require an update
- [ ] All automated tests passed successfully (all builds are green)
Hi @engcom-Bravo. 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).
- [ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue.
- [ ] 3. Add
Area: XXXXXlabel to the ticket, indicating the functional areas it may be related to. - [ ] 4. Verify that the issue is reproducible on
2.4-developbranchDetails
- Add the comment@magento give me 2.4-develop instanceto deploy test instance on Magento infrastructure.
- If the issue is reproducible on2.4-developbranch, please, add the labelReproduced on 2.4.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. Add label
Issue: Confirmedonce verification is complete. - [ ] 6. Make sure that automatic system confirms that report has been added to the backlog.
@magento give me 2.4-develop 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://2f5b4426bca9085531cfd5b372a69717.instances-prod.magento-community.engineering Admin access: https://2f5b4426bca9085531cfd5b372a69717.instances-prod.magento-community.engineering/admin_bcd8 Login: 2511023d Password: 323873661a27
Hi @bhoopatparmar,
Thank you for reporting and collaboration.
Verified the issue on Magento 2.4-develop instance and the issue is reproducible.Kindly refer the attached screenshots.
Manual testing scenarios (*)
- 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
Bundle Product is adding without bundle options to the cart.
Hence Confirming the issue.
Thanks.
:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/AC-11779 is successfully created for this GitHub issue.
:white_check_mark: Confirmed by @engcom-Bravo. Thank you for verifying the issue.
Issue Available: @engcom-Bravo, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.
Hi there, is there any update on this issue? We have seen the same thing occur when setting up a bundle product with 3 or 4 products with all required options.
@magento give me 2.4-develop 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://2f5b4426bca9085531cfd5b372a69717.instances-prod.magento-community.engineering Admin access: https://2f5b4426bca9085531cfd5b372a69717.instances-prod.magento-community.engineering/admin_d5b5 Login: f74f5bee Password: bc09fc92d9c7
Hi @bhoopatparmar,
As per this https://github.com/magento/magento2/pull/38601#issuecomment-2213301852 since it was fixed we are closing this issue.
Thanks.