How do I improve this code? I use it in ListProduct.php
to get the base price in another currency for products in list.phtml
.
How can I do this without objectManager? Why should I not use objectManager? Will it make it slow to process the product listing?
This is from ListProduct.php
, I call the function getProductPrice
from list.phtml
public function getProductBasePrice($product)
{
$store = $product->getStore();
$price = $product->getPrice();
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$priceCurrencyObject = $objectManager->get('Magento\Framework\Pricing\PriceCurrencyInterface');
$price = $priceCurrencyObject->convert($price, $store, null);
return $price;
}