Question

A product has Base Price $30 and Special Price $25. Tiered price discount for this product is $20 for 5 products and there is also a catalog rule active of 25% discount for this product. What will be the product price shown on product page?

a) $15
b) $22.5
c) $25
d) 18.75

Can anyone please help to explain how answer ends as $15 my understanding is 25% discount should be applied on Special Price i.e $25 as it is active price, which should result as 18.75

Was it helpful?

Solution

https://github.com/magento/magento2/blob/2.3-develop/app/code/Magento/Catalog/Model/Product/Type/Price.php#L169

if ($qty === null && $product->getCalculatedFinalPrice() !== null) {
        return $product->getCalculatedFinalPrice();
    }
    $finalPrice = $this->getBasePrice($product, $qty);
    $product->setFinalPrice($finalPrice);
    $this->_eventManager->dispatch('catalog_product_get_final_price', ['product' => $product, 'qty' => $qty]);
    $finalPrice = $product->getData('final_price');
    $finalPrice = $this->_applyOptionsPrice($product, $qty, $finalPrice);
    $finalPrice = max(0, $finalPrice);
    $product->setFinalPrice($finalPrice);
    return $finalPrice;

where event fire and it is calling

https://github.com/magento/magento2/blob/2.3-develop/app/code/Magento/CatalogRule/Observer/ProcessFrontFinalPriceObserver.php

 $finalPrice = min($product->getData('final_price'), $this->rulePricesStorage->getRulePrice($key));
        $product->setFinalPrice($finalPrice);

it will check what is min price

in your case base price :-30 special price :-25

rule price with 25%- 22.5

so whatever min price get from this it will final price for product.

hope it will clear your doubts

All price will be applied on base price and find lowest price from that and it will show as final price.

if set tier price on qty 1 then it will check it contain min price then it will set min price.

otherwise on cart page cal price based on qty again.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top