77namespace Magento \Catalog \Pricing \Render ;
88
99use Magento \Catalog \Pricing \Price ;
10- use Magento \Framework \Pricing \Render ;
1110use Magento \Framework \Pricing \Render \PriceBox as BasePriceBox ;
1211use Magento \Msrp \Pricing \Price \MsrpPrice ;
1312use Magento \Catalog \Model \Product \Pricing \Renderer \SalableResolverInterface ;
1413use Magento \Framework \View \Element \Template \Context ;
1514use Magento \Framework \Pricing \SaleableInterface ;
1615use Magento \Framework \Pricing \Price \PriceInterface ;
1716use Magento \Framework \Pricing \Render \RendererPool ;
17+ use Magento \Framework \App \ObjectManager ;
18+ use Magento \Catalog \Pricing \Price \MinimalPriceCalculatorInterface ;
1819
1920/**
2021 * Class for final_price rendering
@@ -29,25 +30,33 @@ class FinalPriceBox extends BasePriceBox
2930 */
3031 private $ salableResolver ;
3132
33+ /**
34+ * @var MinimalPriceCalculatorInterface
35+ */
36+ private $ minimalPriceCalculator ;
37+
3238 /**
3339 * @param Context $context
3440 * @param SaleableInterface $saleableItem
3541 * @param PriceInterface $price
3642 * @param RendererPool $rendererPool
3743 * @param array $data
3844 * @param SalableResolverInterface $salableResolver
45+ * @param MinimalPriceCalculatorInterface $minimalPriceCalculator
3946 */
4047 public function __construct (
4148 Context $ context ,
4249 SaleableInterface $ saleableItem ,
4350 PriceInterface $ price ,
4451 RendererPool $ rendererPool ,
4552 array $ data = [],
46- SalableResolverInterface $ salableResolver = null
53+ SalableResolverInterface $ salableResolver = null ,
54+ MinimalPriceCalculatorInterface $ minimalPriceCalculator = null
4755 ) {
4856 parent ::__construct ($ context , $ saleableItem , $ price , $ rendererPool , $ data );
49- $ this ->salableResolver = $ salableResolver ?: \Magento \Framework \App \ObjectManager ::getInstance ()
50- ->get (SalableResolverInterface::class);
57+ $ this ->salableResolver = $ salableResolver ?: ObjectManager ::getInstance ()->get (SalableResolverInterface::class);
58+ $ this ->minimalPriceCalculator = $ minimalPriceCalculator
59+ ?: ObjectManager ::getInstance ()->get (MinimalPriceCalculatorInterface::class);
5160 }
5261
5362 /**
@@ -117,11 +126,15 @@ protected function wrapResult($html)
117126 */
118127 public function renderAmountMinimal ()
119128 {
120- /** @var \Magento\Catalog\Pricing\Price\FinalPrice $price */
121- $ price = $ this ->getPriceType (\Magento \Catalog \Pricing \Price \FinalPrice::PRICE_CODE );
122129 $ id = $ this ->getPriceId () ? $ this ->getPriceId () : 'product-minimal-price- ' . $ this ->getSaleableItem ()->getId ();
130+
131+ $ amount = $ this ->minimalPriceCalculator ->getAmount ($ this ->getSaleableItem ());
132+ if ($ amount === null ) {
133+ return '' ;
134+ }
135+
123136 return $ this ->renderAmount (
124- $ price -> getMinimalPrice () ,
137+ $ amount ,
125138 [
126139 'display_label ' => __ ('As low as ' ),
127140 'price_id ' => $ id ,
@@ -150,13 +163,15 @@ public function hasSpecialPrice()
150163 */
151164 public function showMinimalPrice ()
152165 {
166+ $ minTierPrice = $ this ->minimalPriceCalculator ->getValue ($ this ->getSaleableItem ());
167+
153168 /** @var Price\FinalPrice $finalPrice */
154169 $ finalPrice = $ this ->getPriceType (Price \FinalPrice::PRICE_CODE );
155170 $ finalPriceValue = $ finalPrice ->getAmount ()->getValue ();
156- $ minimalPriceAValue = $ finalPrice -> getMinimalPrice ()-> getValue ();
171+
157172 return $ this ->getDisplayMinimalPrice ()
158- && $ minimalPriceAValue
159- && $ minimalPriceAValue < $ finalPriceValue ;
173+ && $ minTierPrice !== null
174+ && $ minTierPrice < $ finalPriceValue ;
160175 }
161176
162177 /**
0 commit comments