From adc623cc0ead1ba483c0c2c0b1e85b56c8c40a1f Mon Sep 17 00:00:00 2001 From: Will Rossiter Date: Tue, 19 Mar 2019 21:57:13 +1300 Subject: [PATCH] Remove NumVisit as no longer in SS4 (Fixes #666) --- src/Model/OrderItem.php | 1 - src/Page/CheckoutPageController.php | 4 ++-- src/Reports/CustomerReport.php | 6 ++++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Model/OrderItem.php b/src/Model/OrderItem.php index bdbae74cc..eb0f9137c 100644 --- a/src/Model/OrderItem.php +++ b/src/Model/OrderItem.php @@ -7,7 +7,6 @@ use SilverStripe\Forms\TextField; use SilverStripe\ORM\FieldType\DBCurrency; - /** * An order item is a product which has been added to an order, * ready for purchase. An order item is typically a product itself, diff --git a/src/Page/CheckoutPageController.php b/src/Page/CheckoutPageController.php index 2d5adb5b0..958e5d5ee 100644 --- a/src/Page/CheckoutPageController.php +++ b/src/Page/CheckoutPageController.php @@ -151,10 +151,10 @@ public function PaymentErrorMessage() return $lastErrorMessage->Message; } - + /** * Override viewer to get correct template for first step - * + * * {@inheritDoc} * @see \SilverStripe\CMS\Controllers\ContentController::getViewer() */ diff --git a/src/Reports/CustomerReport.php b/src/Reports/CustomerReport.php index bc7f07f06..026be0f51 100644 --- a/src/Reports/CustomerReport.php +++ b/src/Reports/CustomerReport.php @@ -30,7 +30,6 @@ public function columns() 'Created' => 'Joined', 'Spent' => 'Spent', 'Orders' => 'Orders', - 'NumVisit' => 'Visits', 'edit' => [ 'title' => 'Edit', 'formatting' => 'edit', @@ -49,12 +48,15 @@ public function query($params) $query = parent::query($params); $query->selectField($this->periodfield, 'FilterPeriod') ->addSelect( - ['"Member"."ID"', '"Member"."FirstName"', '"Member"."Surname"', '"Member"."Email"', '"Member"."NumVisit"', '"Member"."Created"'] + ['"Member"."ID"', '"Member"."FirstName"', '"Member"."Surname"', '"Member"."Email"', '"Member"."Created"'] ) ->selectField('COUNT("SilverShop_Order"."ID")', 'Orders') ->selectField('SUM("SilverShop_Order"."Total")', 'Spent'); + $query->addInnerJoin('SilverShop_Order', '"Member"."ID" = "SilverShop_Order"."MemberID"'); + $query->addGroupBy('"Member"."ID"'); + if (!$query->getOrderBy()) { $query->setOrderBy( [