magento2-page-builder icon indicating copy to clipboard operation
magento2-page-builder copied to clipboard

Fixes: Bundle product with only one product in required bundle option not being added to cart with bundle option

Open bhoopatparmar opened this issue 1 year ago • 40 comments
trafficstars

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

Screenshot 4: mini-cart 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

  1. https://github.com/magento/magento2/pull/38601

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 product carousel using page-builder content that includes the newly created bundle product in the widget. (see screenshot 2). Here I've added the product carousel in home page content
  3. From the front end visit the page & try to add the bundle product from the product slider.(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 (*)

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: code-issue

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 the Magento\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 of Magento\Catalog\ViewModel\Product\OptionsData. Refer the mentioned related PR.

Screenshot 7: code-resolve

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:

  • https://github.com/magento/magento2/pull/38601

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)

Resolved issues:

  1. [x] resolves magento/magento2-page-builder#870: Fixes: Bundle product with only one product in required bundle option not being added to cart with bundle option

bhoopatparmar avatar Apr 11 '24 05:04 bhoopatparmar

@magento run all test

bhoopatparmar avatar Apr 11 '24 05:04 bhoopatparmar

Failed to run the builds. Please try to re-run them later.

@magento run all tests

Bashev avatar Apr 11 '24 06:04 Bashev

@magento run all tests

engcom-Bravo avatar Apr 22 '24 06:04 engcom-Bravo

@magento give me test instance

engcom-Bravo avatar Apr 22 '24 06:04 engcom-Bravo

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 Admin access: https://6b32d64bd6d52d2142ba67dc9522350b.instances-prod.magento-community.engineering/admin_8d9b Login: de1b23e5 Password: 40b573f495a1

@magento run all tests

engcom-Hotel avatar Apr 30 '24 05:04 engcom-Hotel

Hello @bhoopatparmar,

Have you got a chance to look into this PR?

Thanks

engcom-Hotel avatar May 16 '24 05:05 engcom-Hotel

@magento run all tests

bhoopatparmar avatar May 16 '24 07:05 bhoopatparmar

Hi @engcom-Hotel I have fixed static tests that were failing & the other failed tests don't look related to this. Can you confirm these things?

Thanks

bhoopatparmar avatar May 16 '24 10:05 bhoopatparmar

@magento run Functional Tests B2B, Functional Tests CE, Functional Tests EE, WebAPI Tests

engcom-Hotel avatar May 16 '24 11:05 engcom-Hotel

@magento run Functional Tests B2B, Functional Tests CE, Functional Tests EE, WebAPI Tests

engcom-Hotel avatar May 20 '24 07:05 engcom-Hotel

@magento run Functional Tests B2B, Functional Tests CE, Functional Tests EE, WebAPI Tests

engcom-Hotel avatar May 22 '24 05:05 engcom-Hotel

@magento run Functional Tests B2B, WebAPI Tests

engcom-Hotel avatar May 22 '24 07:05 engcom-Hotel

@magento run Functional Tests B2B

engcom-Hotel avatar May 22 '24 10:05 engcom-Hotel

The failed tests seem flaky to me, they are different in 2 consecutive runs. Please refer to the below screenshot for reference:

Functional Test B2B Run 1

image

Run 2

image

WebAPI Tests

Run 1

image

Run 2 image

Hence moving the PR in testing.

Thanks

engcom-Hotel avatar May 22 '24 13:05 engcom-Hotel

@magento create issue

engcom-Bravo avatar May 23 '24 05:05 engcom-Bravo

@magento give me test instance

engcom-Bravo avatar May 23 '24 06:05 engcom-Bravo

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 Admin access: https://6b32d64bd6d52d2142ba67dc9522350b.instances-prod.magento-community.engineering/admin_c842 Login: 7be38355 Password: a85320064cfe

Hi @engcom-Bravo The solution provided in this PR is depended upon the fix provided in this PR : https://github.com/magento/magento2/pull/38601 You can see a new method has been added getViewModel() in the file Magento/CatalogWidget/Block/Product/ProductsList.php that returns the viewModel object. With that fix included, the current PR for the magento2-page-builder will work properly !

Thanks.

bhoopatparmar avatar May 24 '24 06:05 bhoopatparmar

Thanks for the update @bhoopatparmar, but can you please have a look at the below comment:

https://github.com/magento/magento2/pull/38601#pullrequestreview-2081074840

engcom-Hotel avatar May 30 '24 05:05 engcom-Hotel

Hi @engcom-Hotel The PR https://github.com/magento/magento2/pull/38601 has been closed, but the required solution has been merged in the https://github.com/magento/magento2 repo. So, we can move further with this PR for the solution.

bhoopatparmar avatar Jul 08 '24 08:07 bhoopatparmar

@magento give me test instance

engcom-Bravo avatar Jul 09 '24 07:07 engcom-Bravo

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 Admin access: https://6b32d64bd6d52d2142ba67dc9522350b.instances-prod.magento-community.engineering/admin_f8bf Login: c2721286 Password: 05b3c9147191

Hi @bhoopatparmar,

Thanks for your update.

We have verified the issue https://github.com/magento/magento2/issues/38605 and it is now working fine now.

But we have taken this PR changes for product carousel(Page Builder) still it is not fixing the issue.

:x: QA not Passed

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 product carousel using page-builder content that includes the newly created bundle product in the widget. (see screenshot 2). Here I've added the product carousel in home page content
  • From the front end visit the page & try to add the bundle product from the product slider.(see screenshot 3)
  • After clicking Add to Cart observe a warning message in minicart. (see screenshot 4).

:heavy_check_mark: Expected result After Fix 

The bundle product should be added to the cart with bundle options

:x: Actual result After Fix

Screenshot 2024-07-09 at 14 11 22 Screenshot 2024-07-09 at 14 11 34

The bundle product isn’t being added to the cart with bundle options.

Could you please let us know if we are missing anything.

Thanks.

engcom-Bravo avatar Jul 09 '24 10:07 engcom-Bravo

@magento give me test instance

bhoopatparmar avatar Jul 10 '24 06:07 bhoopatparmar

Hi @bhoopatparmar. Thank you for your request. I'm working on Magento instance for you.