Exporter relies on deprecated `money_format()` function
Opened this issue · 4 comments
The money_format()
function is deprecated in PHP 7.4 and removed in PHP 8.0. The function is still used in FriendsOfSylius\SyliusImportExportPlugin\Exporter\Transformer\Handler\IntegerToMoneyFormatHandler::process()
.
Hello @mbabker
Do you think NumberFormatter::formatCurrency is the right choice ?
I have this problem as well; I just installed the plugin and the command line works but if I click on the 'export' button on the order admin page, I get this error about the money_format... so how can I fix that please ?
By doing this:
protected function process($key, $value): ?string
{
$locale = '';
if(isset($GLOBALS['request']) && $GLOBALS['request']) {
$locale = $GLOBALS['request']->getLocale();
}
$fmt = new \NumberFormatter( $locale, \NumberFormatter::CURRENCY );
return $fmt->formatCurrency($value/100, "EUR");
}
it works now ...
However, being only a beginner, I would appreciate if someone here could review this code and check if this is the right way to do it... also, what can I do to override this file in my sylius app ?
Also, is there a way to use the translations to have the column names in my locale instead of in english ?
Thanks in advance!
Any news here? I have the same problem with PHP 8.1