public function processDataArray($orders, $displayedColumns) { $orders = parent::processDataArray($orders, $displayedColumns); $ids = array(); foreach ($orders as &$order) { $ids[$order['ID']] =& $order; foreach ($order as $field => &$value) { if ('status' == $field) { switch ($order[$field]) { case 1: $value = $this->translate('_status_processing'); break; case 2: $value = $this->translate('_STATUS_AWAITING'); break; case 3: $value = $this->translate('_status_shipped'); break; case 4: $value = $this->translate('_status_canceled'); break; default: $value = $this->translate('_status_new'); break; } } if ('totalAmount' == $field || 'capturedAmount' == $field) { if (empty($value)) { $value = '0'; } if (isset($order['Currency'])) { $value .= ' ' . $order['Currency']['ID']; } } if ('dateCompleted' == $field && !$value) { $value = '-'; } } } if ($orders && (isset($displayedColumns['CustomerOrder.taxAmount']) || 1)) { $sql = 'SELECT SUM(ShipmentTax.amount) AS taxAmount, Shipment.orderID AS orderID FROM ShipmentTax LEFT JOIN Shipment ON ShipmentTax.shipmentID=Shipment.ID WHERE Shipment.orderID IN(' . implode(', ', array_keys($ids)) . ') GROUP BY Shipment.orderID'; foreach (ActiveRecord::getDataBySQL($sql) as $row) { $ids[$row['orderID']]['taxAmount'] = round($row['taxAmount'], 2); } } return $orders; }