Created
March 5, 2018 13:46
-
-
Save tdgroot/6458c242d6beab82a4bb2f25107ec563 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Marissen\Theme\Service; | |
use Magento\Catalog\Model\Product; | |
use Magento\Framework\Pricing\PriceCurrencyInterface; | |
class CatalogProductFinalPrice | |
{ | |
/** | |
* @var PriceCurrencyInterface | |
*/ | |
private $priceCurrency; | |
/** | |
* CatalogProductFinalPrice constructor. | |
* @param PriceCurrencyInterface $priceCurrency | |
*/ | |
public function __construct(PriceCurrencyInterface $priceCurrency) | |
{ | |
$this->priceCurrency = $priceCurrency; | |
} | |
/** | |
* @param Product $product | |
* @return float | |
*/ | |
public function get(Product $product): float | |
{ | |
return $this->priceCurrency->convert( | |
$product->getPriceInfo()->getPrice('final_price')->getAmount()->getValue() | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment