1 | <?php |
||
17 | abstract class AbstractOrdersCommand extends Command |
||
18 | { |
||
19 | |||
20 | /** |
||
21 | * @var OrderFactory |
||
22 | */ |
||
23 | private $_orderFactory; |
||
24 | |||
25 | /** |
||
26 | * @var Client |
||
27 | */ |
||
28 | private $_eventClient; |
||
29 | |||
30 | /** |
||
31 | * @var |
||
32 | */ |
||
33 | private $_productCollection; |
||
34 | |||
35 | /** |
||
36 | * AbstractOrdersCommand constructor. |
||
37 | * @param OrderFactory $orderFactory |
||
38 | * @param Client $eventClient |
||
39 | */ |
||
40 | public function __construct(OrderFactory $orderFactory, Client $eventClient) |
||
46 | |||
47 | /** |
||
48 | * Prepare each order for customer and product data to send to PredictionIO |
||
49 | * |
||
50 | * @param $collection |
||
51 | * @return int |
||
52 | */ |
||
53 | protected function _sendCustomerBuyProductData($collection) |
||
72 | |||
73 | /** |
||
74 | * Get a collection of all completed orders from logged in customers |
||
75 | * |
||
76 | * @return array |
||
77 | */ |
||
78 | protected function _getOrderCollection() |
||
88 | |||
89 | /** |
||
90 | * Get a collection of all products in the orders |
||
91 | * |
||
92 | * @param $ordersCollection |
||
93 | * @return array |
||
94 | */ |
||
95 | protected function _getCustomerProductCollection($ordersCollection) |
||
111 | |||
112 | /** |
||
113 | * Count the number of customers in all the orders |
||
114 | * |
||
115 | * @return int |
||
116 | */ |
||
117 | protected function _getCustomerCount() |
||
121 | |||
122 | /** |
||
123 | * Count all the products across all the orders |
||
124 | * |
||
125 | * @return int |
||
126 | */ |
||
127 | protected function _getProductCount() |
||
136 | |||
137 | /** |
||
138 | * Send customer-buys-item events to PredictionIO for all existing orders |
||
139 | * |
||
140 | * @param $customerId |
||
141 | * @param $products |
||
142 | * @return bool |
||
143 | */ |
||
144 | protected function _sendPurchaseEvent($customerId, $products) |
||
154 | } |
||
155 |