From 4423a0d0933f7348c5801f9bb5536862e4b0bdfb Mon Sep 17 00:00:00 2001 From: Alex Collins Date: Tue, 15 Jan 2019 22:08:48 +0000 Subject: [PATCH] Update Top Customers with PostgreSQL support --- src/widgets/TopCustomers.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/widgets/TopCustomers.php b/src/widgets/TopCustomers.php index 8360643..e92533f 100755 --- a/src/widgets/TopCustomers.php +++ b/src/widgets/TopCustomers.php @@ -60,23 +60,23 @@ public function getCustomers() ) ->select( [ - 'count(*) as totalOrders', - 'SUM(orders.totalPrice) as totalRevenue', - 'orders.email', - 'orders.customerId' + 'count(*) as [[totalOrders]]', + 'SUM([[orders.totalPrice]]) as [[totalRevenue]]', + '[[orders.email]]', + '[[orders.customerId]]' ] ) ->from(['orders' => '{{%commerce_orders}}']) - ->where(['orders.isCompleted' => 1]) + ->where(['[[orders.isCompleted]]' => 1]) ->orderBy($this->orderBy . ' desc') - ->groupBy(['orders.email', 'orders.customerId']) + ->groupBy(['[[orders.email]]', '[[orders.customerId]]']) ->limit(5); if($this->includeGuests == 'no') { $query - ->join('INNER JOIN', '{{%commerce_customers}} customers', 'orders.customerId = customers.id') - ->andWhere(['not', ['customers.userId' => null]]); + ->join('INNER JOIN', '{{%commerce_customers}} customers', '[[orders.customerId]] = customers.id') + ->andWhere(['not', ['[[customers.userId]]' => null]]); } $command = $query->createCommand();