Skip to content

Bundles Prices different between the price in the front and the price in the index price table #15311

@PierreLeMaguer

Description

@PierreLeMaguer

I have a difference of 0.01€ between the price of some bundle products front and index table.

Preconditions

  1. Magento 2.1.12

Steps to reproduce

  1. Have one simple product at 11.95€ and another at 6.45.
  2. Configure a bundle product with these two simple products (use multiselect input type).
  3. Set the special price of the bundle product at 90%
  4. Index product prices

Expected result

  1. The price in the table catalog_product_index_price should be the same than the price showed in the product page.

Actual result

There is a difference of 0.01€ .
Table log (select with the two simple product (9242,9250) and the bundle product (10070))

+-----------+-------------------+------------+--------------+---------+-------------+-----------+-----------+------------+
| entity_id | customer_group_id | website_id | tax_class_id | price   | final_price | min_price | max_price | tier_price |
+-----------+-------------------+------------+--------------+---------+-------------+-----------+-----------+------------+
|      9242 |                 0 |          1 |            2 | 11.9500 |     11.9500 |   11.9500 |   11.9500 |       NULL |
|      9242 |                 1 |          1 |            2 | 11.9500 |     11.9500 |   11.9500 |   11.9500 |       NULL |
|      9250 |                 0 |          1 |            2 |  6.4500 |      6.4500 |    6.4500 |    6.4500 |       NULL |
|      9250 |                 1 |          1 |            2 |  6.4500 |      6.4500 |    6.4500 |    6.4500 |       NULL |
|     10070 |                 0 |          1 |            0 |  0.0000 |      0.0000 |   16.5600 |   49.4100 |       NULL |
|     10070 |                 1 |          1 |            0 |  0.0000 |      0.0000 |   16.5600 |   49.4100 |       NULL |
+-----------+-------------------+------------+--------------+---------+-------------+-----------+-----------+------------+

And the price showed in the product page : 16.57€ and prices of each option : 10€76 and 5€81

It looks like there is a problem of rounding price. I noticed that if I modify the method vendor/magento/module-directory/Model/PriceCurrency.php:: round($price) to round at a precision of 4, I retrieve in the front product page the price of 16.56€ (like in the price index table).
At the opposite, if I modify the method vendor/magento/module-bundle/Model/ResourceModel/Indexer/Price.php::_calculateBundleSelectionPrice($priceType), I edit the round SQL methods to a precision of 2 and I have the price of 16.57€ :

+-----------+-------------------+------------+--------------+---------+-------------+-----------+-----------+------------+
| entity_id | customer_group_id | website_id | tax_class_id | price   | final_price | min_price | max_price | tier_price |
+-----------+-------------------+------------+--------------+---------+-------------+-----------+-----------+------------+
|      9242 |                 0 |          1 |            2 | 11.9500 |     11.9500 |   11.9500 |   11.9500 |       NULL |
|      9242 |                 1 |          1 |            2 | 11.9500 |     11.9500 |   11.9500 |   11.9500 |       NULL |
|      9250 |                 0 |          1 |            2 |  6.4500 |      6.4500 |    6.4500 |    6.4500 |       NULL |
|      9250 |                 1 |          1 |            2 |  6.4500 |      6.4500 |    6.4500 |    6.4500 |       NULL |
|     10070 |                 0 |          1 |            0 |  0.0000 |      0.0000 |   16.5700 |   49.4200 |       NULL |
|     10070 |                 1 |          1 |            0 |  0.0000 |      0.0000 |   16.5700 |   49.4200 |       NULL |
+-----------+-------------------+------------+--------------+---------+-------------+-----------+-----------+------------+

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    Component: IndexerIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P3May be fixed according to the position in the backlog.Progress: doneReproduced on 2.1.xThe issue has been reproduced on latest 2.1 releaseReproduced on 2.2.xThe issue has been reproduced on latest 2.2 releaseReproduced on 2.3.xThe issue has been reproduced on latest 2.3 releaseSeverity: S3Affects non-critical data or functionality and does not force users to employ a workaround.stale issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions