Use \Magento\Catalog\Model\ProductFactory
class to get price of product
=> Factory Method :
protected $_product;
public function __construct(
...
\Magento\Catalog\Model\ProductFactory $productFactory,
...
) {
$this->productFactory = $productFactory;
}
public function getPriceById($id)
{
//$id = '21'; //Product ID
$product = $this->productFactory->create();
$productPriceById = $product->load($id)->getPrice();
return $productPriceById;
}
public function getPriceBySku($sku)
{
//$sku = 'testing'; //Product sku
$product = $this->productFactory->create();
$productPriceBySku = $product->loadByAttribute('sku', $sku)->getPrice();
return $productPriceBySku;
}
=> Object Manager Method :
BY Id :
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$productCollection = $objectManager->create('Magento\Catalog\Model\Product')->load(your-product-id);
$productPriceById = $productCollection->getPrice();
By Sku :
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$productCollection = $objectManager->create('Magento\Catalog\Model\Product')->loadByAttribute('sku', your-sku);
$productPriceBySku = $productCollection->getPrice();