Description
Preconditions and environment
- Magento version 2.4.5-p9
Steps to reproduce
By selection product i'm referring to the child item e.g. a bundle of notepad and pen consisting of 2 simple products where I want to calculate the price based on a percentage of these products price.
Simple Products
Notepad - £10
Pen - £1
Bundle Item
Notepad Bundle Including Pen
(Here we are going to discount the bundle by 10% because we are buying a bundle however would like this to stay up to date with future updated in prices say an increase in the Notepad price causes the bundle price to increase proportionately)
- Set bundle item to non dynamic pricing so we can control selection items (Notepad, Pen) with percentage based pricing.
- Set bundle price to 0. (This feels to be like an additional charge for the bundle however will price each part of the bundle separately)
- Set each selection item to 90 for the percentage giving individual prices for the items of £9 (10 x (90 / 100)) and £0.90 (1 x (90 / 100)) and a total bundle price of £9.90.
- Visit product page on frontend price
Expected result
Price should show £9.90 with £9 for the notepad and £0.90 for the pen (90% of the simple products)
This would allow you to create percentage based discounts when purchasing bundles of products together and allows for pricing to stay up to date even with future price increased of the child products.
Actual result
Percentage seems to apply to the bundle product's price. If f I set a price of £10 for the bundle product the selection products with percentage based prices show as £9 when I believe this should show as 90% of the selection products price. I cannot see an example of when you would ever want to set a percentage of a fixed price already set on that page, you could just set a fixed price.
Additional information
I have tested on a vanilla 2.4 and looked at the source and the class Magento/Bundle/Model/Product/Price has not been modified for years and seems to show percent calculated on the bundleProduct:
if ($bundleProduct->getPriceType() == self::PRICE_TYPE_DYNAMIC) {
$totalQty = $bundleQty * $selectionQty;
if (!$takeTierPrice || $totalQty === 0) {
$totalQty = 1;
}
$price = $selectionProduct->getFinalPrice($totalQty);
} else {
if ($selectionProduct->getSelectionPriceType()) {
// percent
$product = clone $bundleProduct;
$product->setFinalPrice($this->getPrice($product));
$this->_eventManager->dispatch(
'catalog_product_get_final_price',
['product' => $product, 'qty' => $bundleQty]
);
$price = $product->getData('final_price') * ($selectionProduct->getSelectionPriceValue() / 100);
} else {
// fixed
$price = $selectionProduct->getSelectionPriceValue();
}
}
When I feel it should be calculated on the child product:
if ($bundleProduct->getPriceType() == self::PRICE_TYPE_DYNAMIC) {
$totalQty = $bundleQty * $selectionQty;
if (!$takeTierPrice || $totalQty === 0) {
$totalQty = 1;
}
$price = $selectionProduct->getFinalPrice($totalQty);
} else {
if ($selectionProduct->getSelectionPriceType()) {
// percent
$this->_eventManager->dispatch(
'catalog_product_get_final_price',
['product' => $selectionProduct, 'qty' => $bundleQty]
);
$price = $selectionProduct->getFinalPrice() * ($selectionProduct->getSelectionPriceValue() / 100);
} else {
// fixed
$price = $selectionProduct->getSelectionPriceValue();
}
}
This may have always be like this as I had a patch similar to above in place it seemed that didn't get applied however unsure if this is as intended or a bug however does not seem logical to myself to ever have this work in such a way.
Triage and priority
- 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”.
Metadata
Metadata
Assignees
Type
Projects
Status