magento2 get formatted price

Sometime We need to get minimum price, maximum price or whatever price in Magento2, you will get any price without currency symbol. so Here We will understand to get formatted Price.
Suppose I need a minimum Price on Category Page, Then It will fetch price without currency symbol.

$minPrice = $_productCollection->getMinPrice();
$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); // Object Manager
$priceHelper = $objectManager->create('Magento\Framework\Pricing\Helper\Data'); // Pricing Helper
$minPrice = $minPrice; //Your Price
$formattedPrice = $priceHelper->currency($minPrice, true, false); //formatted Price

It will return currency symbol according to current currency of your store.

I hope It will help you.

Leave a Reply