Skip to content

Commit 52b5c64

Browse files
author
valdislav
committed
MAGETWO-35628: Refactor queries for Magento\Reports\Model\Resource\Customer\Collection - no found usages clients uses order report implementation
1 parent 85dfbb0 commit 52b5c64

File tree

1 file changed

+0
-84
lines changed

1 file changed

+0
-84
lines changed

app/code/Magento/Reports/Model/Resource/Customer/Collection.php

Lines changed: 0 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -152,90 +152,6 @@ public function addCustomerName()
152152
return $this;
153153
}
154154

155-
/**
156-
* Order for each customer
157-
*
158-
* @param string $fromDate
159-
* @param string $toDate
160-
* @return $this
161-
*/
162-
public function joinOrders($fromDate = '', $toDate = '')
163-
{
164-
if ($fromDate != '' && $toDate != '') {
165-
$dateFilter = " AND orders.created_at BETWEEN '{$fromDate}' AND '{$toDate}'";
166-
} else {
167-
$dateFilter = '';
168-
}
169-
170-
$this->getSelect()->joinLeft(
171-
['orders' => $this->getTable('sales_order')],
172-
"orders.customer_id = e.entity_id" . $dateFilter,
173-
[]
174-
);
175-
176-
return $this;
177-
}
178-
179-
/**
180-
* Add orders count
181-
*
182-
* @return $this
183-
*/
184-
public function addOrdersCount()
185-
{
186-
$this->getSelect()->columns(
187-
["orders_count" => "COUNT(orders.entity_id)"]
188-
)->where(
189-
'orders.state <> ?',
190-
\Magento\Sales\Model\Order::STATE_CANCELED
191-
)->group(
192-
"e.entity_id"
193-
);
194-
195-
return $this;
196-
}
197-
198-
/**
199-
* Order summary info for each customer such as orders_count, orders_avg_amount, orders_total_amount
200-
*
201-
* @param int $storeId
202-
* @return $this
203-
*/
204-
public function addSumAvgTotals($storeId = 0)
205-
{
206-
$adapter = $this->getConnection();
207-
$baseSubtotalRefunded = $adapter->getIfNullSql('orders.base_subtotal_refunded', 0);
208-
$baseSubtotalCanceled = $adapter->getIfNullSql('orders.base_subtotal_canceled', 0);
209-
210-
/**
211-
* calculate average and total amount
212-
*/
213-
$expr = $storeId ==
214-
0 ?
215-
"(orders.base_subtotal - {$baseSubtotalCanceled} - {$baseSubtotalRefunded}) * orders.base_to_global_rate" :
216-
"orders.base_subtotal - {$baseSubtotalCanceled} - {$baseSubtotalRefunded}";
217-
218-
$this->getSelect()->columns(
219-
["orders_avg_amount" => "AVG({$expr})"]
220-
)->columns(
221-
["orders_sum_amount" => "SUM({$expr})"]
222-
);
223-
224-
return $this;
225-
}
226-
227-
/**
228-
* Order by total amount
229-
*
230-
* @param string $dir
231-
* @return $this
232-
*/
233-
public function orderByTotalAmount($dir = self::SORT_ORDER_DESC)
234-
{
235-
$this->getSelect()->order("orders_sum_amount {$dir}");
236-
return $this;
237-
}
238-
239155
/**
240156
* Add order statistics
241157
*

0 commit comments

Comments
 (0)