Question

I am exporting Magento 2.1.9 Saler Order Grid to CSV and XML formats using the provided buttons. But when I open the file in Excel the currency symbol is missing in Grand Total (Base) and Grand Total (Purchased) columns.

I need the currency symbols in all price colums when exporting.

Was it helpful?

Solution

Ok here is what I did to achieve the desired output.

  • Created a new Module and override the Convert Classes (ConvertToCsv / ConvertToXml) from vendor/magento/module-ui/Model/Export/
  • Replaced following code

foreach ($items as $item) {
    $this->metadataProvider->convertDate($item, $component->getName());
    $stream->writeCsv($this->metadataProvider->getRowData($item, $fields, $options));
}    

With

foreach ($items as $item) {
    // Add currency
    $item['base_grand_total'] = $item['base_currency_code'].$item['base_grand_total'];
    $item['grand_total'] = $item['order_currency_code'].$item['grand_total'];
    $item['subtotal'] = $item['base_currency_code'].$item['subtotal'];
    $item['shipping_and_handling'] = $item['base_currency_code'].$item['shipping_and_handling'];

    $this->metadataProvider->convertDate($item, $component->getName());
    $stream->writeCsv($this->metadataProvider->getRowData($item, $fields, $options));
}

It did the trick for me - hope someone will find it useful or someone will provide a better solution.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top