I created a custom block and call it in my controller
<?php
namespace Vendor\Module\Block\Product;
class Price extends \Magento\Framework\View\Element\Template {
/** @var \Magento\Framework\View\Result\Page */
protected $_product;
protected $_layout;
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
\Magento\Catalog\Model\Product $product,
\Magento\Framework\View\LayoutInterface $layout
) {
$this->_product = $product;
$this->_layout = $layout;
parent::__construct($context);
}
public function getPrice(\Magento\Catalog\Model\Product $product)
{
$priceRender = $this->getLayout()->getBlock('product.price.render.default');
if (!$priceRender) {
$priceRender = $this->getLayout()->createBlock(
\Magento\Framework\Pricing\Render::class,
'product.price.render.default',
['data' => ['price_render_handle' => 'catalog_product_prices']]
);
}
$price = '';
if ($priceRender) {
$price = $priceRender->render(
\Magento\Catalog\Pricing\Price\FinalPrice::PRICE_CODE,
$product,
[
'display_minimal_price' => true,
'use_link_for_as_low_as' => true,
'zone' => \Magento\Framework\Pricing\Render::ZONE_ITEM_LIST
]
);
}
return $price;
}
}
Call it in controller
$blockInstance = $this->_objectManager->get('Vendor\Module\Block\Product\Price');
$productData['price']= $blockInstance->getPrice($product);