Skip to content

Instantly share code, notes, and snippets.

@tdgroot
Created March 5, 2018 13:46
Show Gist options
  • Save tdgroot/6458c242d6beab82a4bb2f25107ec563 to your computer and use it in GitHub Desktop.
Save tdgroot/6458c242d6beab82a4bb2f25107ec563 to your computer and use it in GitHub Desktop.
<?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