Details
-
Type:
Bug
-
Status: Done/Fixed
-
Priority:
Minor
-
Resolution: Fixed/Completed
-
Affects Version/s: 4.6.28, 4.7.23
-
Fix Version/s: 4.7.31
-
Component/s: CiviContribute
-
Labels:
-
Versioning Impact:Patch (backwards-compatible bug fixes)
-
Documentation Required?:Developer Doc
-
Funding Source:Contributed Code
-
Verified?:No
Description
When using the hook civicrm_batchItems to transform the csv export format, the hook itself functions as expected. My code:
function fintrxn_civicrm_batchItems(&$results, &$items) {
// change batch items when exporting to meet aivl criteria
CRM_Fintrxn_Batch::batchItems($results, $items);
}
public static function batchItems ($results, &$items) {
// clean out items array
$items = array();
// get mapping from JSON file
$mapping = self::getExportMapping();
// go through all results
foreach ($results as $result) {
// split transaction date in year and month
$transactionDate = new DateTime($result['trxn_date']);
$result['trxn_year'] = $transactionDate->format('Y');
$result['trxn_month'] = $transactionDate->format('n');
// create item array based on mapping
$item = $mapping;
foreach ($item as $itemKey => $itemValue) {
if (isset($result[$itemValue])) {
$item[$itemKey] = $result[$itemValue];
}
}
$items[] = $item;
}
}
But the actual output does not reflect my changes in the hook. This is because the code in
CRM_Financial_BAO_ExportFormat_CSV does not actually process the hook results.
In my opinion it should be:
$batchItems[] = &$financialItems[key($financialItems)]; $queryResults[] = get_object_vars($dao); } CRM_Utils_Hook::batchItems($queryResults, $batchItems); $batchItems['headers'] = self::formatHeaders($batchItems); self::export($batchItems);
I have tested this locally and it works.