/** * @param array $statisticsEntities * @param Product $product */ protected function loadOneProductStatistics(array $statisticsEntities, Product $product) { $productId = $product->getProductId(); $actualStatisticsData = $statisticsEntities[0]; $allTimeStatisticsData = $this->getAllTimeProductsStatisticsByProductId($productId); $allViews = 0; $allOrders = 0; $allConversion = 0; $allTotal = 0; $views = $this->getUniqueViews($actualStatisticsData); if ($allTimeStatisticsData) { $allViews = $this->getUniqueViews($allTimeStatisticsData); } $orderCount = $this->getUniqueOrders($actualStatisticsData); if ($allTimeStatisticsData) { $allOrders = $this->getUniqueViews($allTimeStatisticsData); } $conversion = $this->getConversion($actualStatisticsData); if ($allTimeStatisticsData) { $allConversion = $this->getConversion($allTimeStatisticsData); } $total = $this->getTotal($actualStatisticsData); if ($allTimeStatisticsData) { $allTotal = $this->getTotal($allTimeStatisticsData); } $picture = ''; if ($product->getPicture()) { $picture = $this->settingService->get('picture_url') . $product->getPicture(); } $name = $product->getName(); $sku = $product->getSku(); $availableDateTime = $product->getAvailableDate(); $availableDate = $availableDateTime->format('m.Y.'); $score = $this->getScore($actualStatisticsData); $this->collectedData[] = array('picture' => $picture, 'name' => $name, 'sku' => $sku, 'availableDate' => $availableDate, 'score' => $score, 'orderCount' => $orderCount, 'conversion' => $conversion, 'total' => $total, 'views' => $views, 'allTimeViews' => $allViews, 'allTimeOrderCount' => $allOrders, 'allTimeConversion' => $allConversion, 'allTimeTotal' => $allTotal); }
/** * @param Product $product * @return int */ protected function getProductId(Product $product) { return $product->getProductId(); }