magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.56k stars 9.32k forks source link

[Issue] Fixes: Bundle product with only one product in required bundle option not being added to cart with bundle option. #38605

Closed m2-assistant[bot] closed 4 months ago

m2-assistant[bot] commented 7 months ago

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: image 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: image 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: image As we have created a widget, a bundle product is visible on the home page in the widget.

Screenshot 4: image 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 (*)

  1. 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)
  2. 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)
  3. From the front end visit the widget & try to add the bundle product from the widget product list.(see screenshot 3)
  4. 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: image

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: image

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: image

Contribution checklist (*)

m2-assistant[bot] commented 7 months ago

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:

engcom-Bravo commented 7 months ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 7 months ago

Hi @engcom-Bravo. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 7 months ago

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

engcom-Bravo commented 7 months ago

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 (*)

Screenshot 2024-04-15 at 13 05 52 Screenshot 2024-04-15 at 13 09 03

Bundle Product is adding without bundle options to the cart.

Hence Confirming the issue.

Thanks.

github-jira-sync-bot commented 7 months ago

:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/AC-11779 is successfully created for this GitHub issue.

m2-assistant[bot] commented 7 months ago

: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.

nicholasfishjgm commented 7 months ago

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.

engcom-Bravo commented 4 months ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 4 months ago

Hi @engcom-Bravo. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 4 months ago

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

engcom-Bravo commented 4 months ago

Hi @bhoopatparmar,

As per this https://github.com/magento/magento2/pull/38601#issuecomment-2213301852 since it was fixed we are closing this issue.

Thanks.