/** * Add rate votes * * @return $this */ public function addRateVotes() { foreach ($this->getItems() as $item) { $votesCollection = $this->_voteFactory->create()->getResourceCollection()->setReviewFilter($item->getId())->setStoreFilter($this->_storeManager->getStore()->getId())->addRatingInfo($this->_storeManager->getStore()->getId())->load(); $item->setRatingVotes($votesCollection); } return $this; }
/** * Get review rating collection * * @return VoteCollection */ public function getRating() { if (!$this->getRatingCollection()) { $ratingCollection = $this->_voteFactory->create()->getResourceCollection()->setReviewFilter($this->getReviewId())->addRatingInfo($this->_storeManager->getStore()->getId())->setStoreFilter($this->_storeManager->getStore()->getId())->load(); $this->setRatingCollection($ratingCollection->getSize() ? $ratingCollection : false); } return $this->getRatingCollection(); }
/** * Aggregate options * * @param \Magento\Review\Model\Rating\Option $option * @return void */ public function aggregate($option) { $vote = $this->_ratingOptionVoteF->create()->load($option->getVoteId()); $this->aggregateEntityByRatingId($vote->getRatingId(), $vote->getEntityPkValue()); }