In the code below, I get the product price by identifier, but only the first product price is returned for different product id. Can help me ?
public function getBundlePriceByid($product_id){
$_store = 1;
$this->emulation->startEnvironmentEmulation($_store, \Magento\Framework\App\Area::AREA_FRONTEND, true);
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$product = $objectManager->get('Magento\Catalog\Model\Product')->load($product_id);
$prices = $product->getPriceInfo()->getPrice('final_price')->getMaximalPrice()->getValue();
$this->emulation->stopEnvironmentEmulation();
return $prices;
}
// 1 = 250$
// 7 = 260$
// 8 = 270$
$prIds= array(1,7,8);
foreach($prIds as $prId){
echo $this->getBundlePriceByid($prId);
}
returns only 250$
This code I call in Cron Job