Use the below code in your class or helper.
protected $_productRepository;
public function __construct(
\Magento\Catalog\Model\ProductRepository $productRepository,
) {
$this->_productRepository = $productRepository;
}
public function getSpecialPriceById($id)
{
$product = $this->_productRepository->getById($id);
return $product->getSpecialPrice();
}
public function getSpecialPriceBySku($sku)
{
$product_id = $block->getProduct()->getId();
$product = $this->_productRepository->get($sku);
return $product->getSpecialPrice();
}
public function getPriceById($id)
{
$product = $this->_productRepository->create();
return $product->load($id)->getPrice();
}
public function getPriceBySku($sku)
{
$product = $this->_productRepository->create();
return $product->loadByAttribute('sku', $sku)->getPrice();
}
call this function using block or helper as you want.
call this function using block or helper as you want.
$id = '1';
$orginalPrice = $_product->getPrice();
$sku = 'some-ski';
//special price
$block->getSpecialPriceById($id);
$block->getSpecialPriceBySku($sku);
//normal price
$block->getPriceById($id);
$block->getPriceBySku($sku);
Please try the below code if you want to use it with object manager but it is highly not recommended.
$product_id = $block->getProduct()->getId();
$_product = $objectManager->get('Magento\Catalog\Model\ProductRepository')->create()->load($product_id);
$orginalPrice = $_product->getPrice();
$specialPrice = $_product->getSpecialPrice();