Я хочу изменить код, который генерирует счетчик обзора summary.phtml, я хочу добавить фильтр к счетчику, я сделал это как на вкладке, так и в сводке обзора с помощью вкладки, но не могунайдите код, который его генерирует, в summary.phtml
summary.phtml
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
// @codingStandardsIgnoreFile
/** @var \Magento\Review\Block\Product\ReviewRenderer $block */
$url = $block->getReviewsUrl() . '#reviews';
$urlForm = $block->getReviewsUrl() . '#review-form';
?>
<?php if ($block->isReviewEnabled() && $block->getReviewsCount()): ?>
<?php $rating = $block->getRatingSummary(); ?>
<div class="product-reviews-summary<?= !$rating ? ' no-rating' : '' ?>" itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
<?php if ($rating):?>
<div class="rating-summary">
<span class="label"><span><?= $block->escapeHtml(__('Rating')) ?>:</span></span>
<div class="rating-result" title="<?= $block->escapeHtmlAttr($rating); ?>%">
<span style="width:<?= $block->escapeHtmlAttr($rating); ?>%">
<span>
<span itemprop="ratingValue"><?= $block->escapeHtml($rating); ?></span>% of <span itemprop="bestRating">100</span>
</span>
</span>
</div>
</div>
<?php endif;?>
<div class="reviews-actions">
<a class="action view"
href="<?= $block->escapeUrl($url) ?>">
<span itemprop="reviewCount"><?= $block->escapeHtml($block->getReviewsCount()) ?></span>
<span><?= ($block->getReviewsCount() == 1) ? $block->escapeHtml(__('Review')) : $block->escapeHtml(__('Reviews')) ?></span>
</a>
<a class="action add" href="<?= $block->escapeUrl($urlForm) ?>"><?= $block->escapeHtml(__('Add Your Review')) ?></a>
</div>
</div>
<?php elseif ($block->isReviewEnabled() && $block->getDisplayIfEmpty()): ?>
<div class="product-reviews-summary empty">
<div class="reviews-actions">
<a class="action add" href="<?= $block->escapeUrl($urlForm) ?>">
<?= $block->escapeHtml(__('Be the first to review this product')) ?>
</a>
</div>
</div>
<?php endif; ?>
Если функция $ block-> getReviewsCount (), очевидно, ссылается на ReviewRenderer.php, но функция, похоже, просто вызываетсама
ReviewRenderer.php
<?php
/**
* Review renderer
*
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Review\Block\Product;
use Magento\Catalog\Block\Product\ReviewRendererInterface;
use Magento\Catalog\Model\Product;
use Magento\Review\Observer\PredispatchReviewObserver;
/**
* Class ReviewRenderer
*/
class ReviewRenderer extends \Magento\Framework\View\Element\Template implements ReviewRendererInterface
{
/**
* Array of available template name
*
* @var array
*/
protected $_availableTemplates = [
self::FULL_VIEW => 'Magento_Review::helper/summary.phtml',
self::SHORT_VIEW => 'Magento_Review::helper/summary_short.phtml',
];
/**
* Review model factory
*
* @var \Magento\Review\Model\ReviewFactory
*/
protected $_reviewFactory;
/**
* @param \Magento\Framework\View\Element\Template\Context $context
* @param \Magento\Review\Model\ReviewFactory $reviewFactory
* @param array $data
*/
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
\Magento\Review\Model\ReviewFactory $reviewFactory,
array $data = []
) {
$this->_reviewFactory = $reviewFactory;
parent::__construct($context, $data);
}
/**
* Review module availability
*
* @return string
*/
public function isReviewEnabled() : string
{
return $this->_scopeConfig->getValue(
PredispatchReviewObserver::XML_PATH_REVIEW_ACTIVE,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
);
}
/**
* Get review summary html
*
* @param Product $product
* @param string $templateType
* @param bool $displayIfNoReviews
*
* @return string
*/
public function getReviewsSummaryHtml(
\Magento\Catalog\Model\Product $product,
$templateType = self::DEFAULT_VIEW,
$displayIfNoReviews = false
) {
if (!$product->getRatingSummary()) {
$this->_reviewFactory->create()->getEntitySummary($product, $this->_storeManager->getStore()->getId());
}
if (!$product->getRatingSummary() && !$displayIfNoReviews) {
return '';
}
// pick template among available
if (empty($this->_availableTemplates[$templateType])) {
$templateType = self::DEFAULT_VIEW;
}
$this->setTemplate($this->_availableTemplates[$templateType]);
$this->setDisplayIfEmpty($displayIfNoReviews);
$this->setProduct($product);
return $this->toHtml();
}
/**
* Get ratings summary
*
* @return string
*/
public function getRatingSummary()
{
return $this->getProduct()->getRatingSummary()->getRatingSummary();
}
/**
* Get count of reviews
*
* @return int
*/
public function getReviewsCount()
{
return $this->getProduct()->getRatingSummary()->getReviewsCount();
}
/**
* Get review product list url
*
* @param bool $useDirectLink allows to use direct link for product reviews page
* @return string
*/
public function getReviewsUrl($useDirectLink = false)
{
$product = $this->getProduct();
if ($useDirectLink) {
return $this->getUrl(
'review/product/list',
['id' => $product->getId(), 'category' => $product->getCategoryId()]
);
}
return $product->getUrlModel()->getUrl($product, ['_ignore_category' => true]);
}
}
Заранее спасибо, если кто-то может помочь, пожалуйста
Крис