/** * @return Product */ public function setDataToObject() { $this->statisticsObject = null; $objects = $this->object->getProductStatistics(); if ($objects->count()) { foreach ($objects->toArray() as $object) { if ($object->getTimeKey() == $this->timeKey) { $this->statisticsObject = $object; } } } if (!$this->statisticsObject) { $this->statisticsObject = new ProductStatistics(); } $this->statisticsObject->setTimeKey($this->timeKey); $this->statisticsObject->setViews($this->getFormattedData('views', 'integer')); $this->statisticsObject->setUniqueViews($this->getFormattedData('uniqueViews', 'integer')); $this->statisticsObject->setProduct($this->object); $this->entityManager->persist($this->statisticsObject); parent::setDataToObject(); }
/** * @param Product $product * @return array */ protected function getProductStatistics(Product $product) { return $product->getProductStatistics()->toArray(); }
/** * @param Product $product * @return \Doctrine\Common\Collections\Collection */ protected function getProductStatisticsCollection(Product $product) { return $product->getProductStatistics(); }