magento2: Admin Loads and Saves Bundle Product Child Items Price if Set to $0 - Incorrectly Inflates Product Price

Summary of Issue

When a child item of a bundle product has a price of $0.00, editing the parent bundle product in the admin sets the child items as their product price. Then when you save the parent bundle product, those child product prices are saved and overwrites the $0.00 set to them. This results in an undesired inflation of the parent bundle product price.

To avoid this you have to manually set the child item price to $0.00 prior to saving.

This issue did not exist in v2.4.1. It was added by a code addition in v2.4.2.

Preconditions (*)

  1. Magento version 2.4.2 (not present in version 2.4.1)
  2. Magento Admin

Steps to reproduce (*)

  1. Create a bundle product
  2. Set at least one Bundle Item to the product using the Add Option button with the following configuration:
    1. Input Type: Checkbox
    2. Required: Yes
    3. Is Default: Yes
    4. Price: $0.00
    5. Price Type: Fixed
    6. Default Quantity: 1
  3. Save product
    1. Note that the price of that child item is not set to $0.00 like was set in step 2
    2. Query this product in the database in table catalog_product_bundle_selection and notice that the selection_price_value column is set to 0.0000
  4. Save the product
    1. Query this product in the database in table catalog_product_bundle_selection and notice that the selection_price_value column is NOT set to 0.0000 - instead it’s set to the price of the child product

Expected result (*)

  1. A price of $0.00 should be respected and not overridden by the child products price

Actual result (*)

  1. The product price is saved - overriding the $0.00 and thus un-intentionally inflating the product price.

Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 17 (3 by maintainers)

Most upvoted comments

The bug is here:

# vendor/magento/module-bundle/Model/Product/LinksList.php
# Line 56

            $bundledProductPrice = $selection->getSelectionPriceValue();
            if ($bundledProductPrice <= 0) {
                $bundledProductPrice = $selection->getPrice();
            }

The comparator should be just < - not <=.

So the code should be:

            $bundledProductPrice = $selection->getSelectionPriceValue();
            if ($bundledProductPrice < 0) {
                $bundledProductPrice = $selection->getPrice();
            }