-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Description
I have a difference of 0.01€ between the price of some bundle products front and index table.
Preconditions
- Magento 2.1.12
Steps to reproduce
- Have one simple product at 11.95€ and another at 6.45.
- Configure a bundle product with these two simple products (use multiselect input type).
- Set the special price of the bundle product at 90%
- Index product prices
Expected result
- 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