I am using the following code to get from magento 2.4.6 product’s final price, simple or configurable, to a feed json file. Final price I mean that I need the lower discounted price in product, either coming from special price or from a catalog rule.
public function addPriceData(StoreInterface $store, $product, array &$data, array $childProducts): void
{
$priceData = $this->prices->getPriceData(
$store,
$product,
$childProducts
);
$data['Prices'] = $priceData['Prices'];
$data['SalePrices'] = $priceData['SalePrices'];
$data['GroupPrices'] = $priceData['GroupPrices'];
}
But it happens something wired. Some of my products get the right price some are not. It returns to me nothing. I have no error in logs.
Any help please to make my function better?