26 protected $_template =
'Magento_Review::customer/view.phtml';
80 $this->_reviewFactory = $reviewFactory;
81 $this->_voteFactory = $voteFactory;
82 $this->_ratingFactory = $ratingFactory;
98 $this->setReviewId($this->
getRequest()->getParam(
'id',
false));
108 if ($this->getReviewId() && !$this->getProductCacheData()) {
110 $this->setProductCacheData(
$product);
112 return $this->getProductCacheData();
122 if ($this->getReviewId() && !$this->getReviewCachedData()) {
123 $this->setReviewCachedData($this->_reviewFactory->create()->load($this->getReviewId()));
125 return $this->getReviewCachedData();
135 return $this->
getUrl(
'review/customer');
145 if (!$this->getRatingCollection()) {
146 $ratingCollection = $this->_voteFactory->create()->getResourceCollection()->setReviewFilter(
149 $this->_storeManager->getStore()->getId()
151 $this->_storeManager->getStore()->getId()
157 return $this->getRatingCollection();
167 if (!$this->getRatingSummaryCache()) {
168 $this->setRatingSummaryCache(
169 $this->_ratingFactory->create()->getEntitySummary($this->
getProductData()->getId())
172 return $this->getRatingSummaryCache();
182 if (!$this->getTotalReviewsCache()) {
183 $this->setTotalReviewsCache(
184 $this->_reviewFactory->create()->getTotalReviews($this->
getProductData()->getId()),
186 $this->_storeManager->getStore()->getId()
189 return $this->getTotalReviewsCache();
200 return $this->
formatDate($date, \IntlDateFormatter::LONG);
214 $displayIfNoReviews =
false 216 if (!
$product->getRatingSummary()) {
217 $this->_reviewFactory->create()->getEntitySummary(
$product, $this->_storeManager->getStore()->getId());
227 return $this->currentCustomer->getCustomerId() ? parent::_toHtml() :
'';
__construct(\Magento\Catalog\Block\Product\Context $context, \Magento\Catalog\Api\ProductRepositoryInterface $productRepository, \Magento\Review\Model\ReviewFactory $reviewFactory, \Magento\Review\Model\Rating\Option\VoteFactory $voteFactory, \Magento\Review\Model\RatingFactory $ratingFactory, \Magento\Customer\Helper\Session\CurrentCustomer $currentCustomer, array $data=[])
formatDate( $date=null, $format=\IntlDateFormatter::SHORT, $showTime=false, $timezone=null)
getReviewsSummaryHtml(\Magento\Catalog\Model\Product $product, $templateType=false, $displayIfNoReviews=false)
getUrl($route='', $params=[])