我是奏鸣曲管理包的新手。现在,我尝试导出一个包含以下内容的 csv 文件:“customer.phone”、“order.total”...但是当我打开 csv 文件时,“order.total”字段中只有“99.99”,我希望将其导出为“AUD $99.99”,有人知道如何实现吗?非常感谢!代码在这里:
public function getExportFields() {
return array('id','customer.First_name','customer.Last_name',
'customer.contact','total_amount'
);
}
最佳答案
您需要在您的Order
类中定义方法getTotalAmountFormated
,并使其返回您需要的字符串。然后在从 getExportFields
返回的数组中添加 totalAmountFormated
(或 total_amount_formated
,我认为两者都应该有效)。
public function getExportFields() {
return array('id','customer.First_name','customer.Last_name',
'customer.contact','totalAmountFormated'
);
}
关于symfony - 自定义 Sonata Admin bundle 导出的 CSV 内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25861799/