ltsecurityinc安防产品在线商城代码
This commit is contained in:
+14
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
/**
|
||||
* @author Olegnax
|
||||
* @package Olegnax_ProductReviewsSummary
|
||||
* @copyright Copyright (c) 2023 Olegnax (http://olegnax.com/). All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
namespace Olegnax\ProductReviewsSummary\Block\Adminhtml\System\Config\Form;
|
||||
|
||||
class Info extends \Olegnax\Core\Block\Adminhtml\System\Config\Form\Info
|
||||
{
|
||||
}
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Olegnax ProductReviewsSummary
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Olegnax.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.olegnax.com/license
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Olegnax
|
||||
* @package Olegnax_ProductReviewsSummary
|
||||
* @copyright Copyright (c) 2023 Olegnax (http://www.olegnax.com/)
|
||||
* @license https://www.olegnax.com/license
|
||||
*/
|
||||
|
||||
namespace Olegnax\ProductReviewsSummary\Block\Html;
|
||||
|
||||
use Magento\Review\Block\Product\View;
|
||||
|
||||
class ReviewSummary extends View {
|
||||
|
||||
protected function _construct() {
|
||||
$_avg_arr = [];
|
||||
$rating_votes = [];
|
||||
$_items = $this->getReviewsItems();
|
||||
if (count($_items)) {
|
||||
foreach ($_items as $_review) {
|
||||
$_rating_votes = $_review->getRatingVotes();
|
||||
if (count($_rating_votes)) {
|
||||
$_avg_arr_review = [];
|
||||
foreach ($_rating_votes as $_vote) {
|
||||
$_avg_arr_review[] = $_vote->getValue();
|
||||
|
||||
$_rating_id = $_vote->getRatingId();
|
||||
if (array_key_exists($_rating_id, $rating_votes)) {
|
||||
foreach (['percent', 'value'] as $field) {
|
||||
$value = $rating_votes[$_rating_id]->getData($field);
|
||||
$value[] = $_vote->getData($field);
|
||||
$rating_votes[$_rating_id]->setData($field, $value);
|
||||
}
|
||||
} else {
|
||||
foreach (['percent', 'value'] as $field) {
|
||||
$_vote->setData($field, [$_vote->getData($field)]);
|
||||
}
|
||||
$rating_votes[$_rating_id] = $_vote;
|
||||
}
|
||||
}
|
||||
$_avg_arr[] = $this->getAverage($_avg_arr_review);
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->setRatingVotes($rating_votes);
|
||||
$this->setNumberRatings($_avg_arr);
|
||||
$this->setData('average_rating', round($this->getAverage($_avg_arr), 1));
|
||||
}
|
||||
|
||||
public function getPercent() {
|
||||
return round($this->getData('average_rating') * 100 / 5);
|
||||
}
|
||||
|
||||
private function getAverage(array $array) {
|
||||
$count = count($array);
|
||||
if (!$count) {
|
||||
return 0;
|
||||
}
|
||||
return array_sum($array) / $count;
|
||||
}
|
||||
|
||||
private function setNumberRatings(array $array) {
|
||||
$array = array_map('round', $array);
|
||||
$array = array_map('intval', $array);
|
||||
rsort($array, SORT_NUMERIC);
|
||||
$_array = [
|
||||
5 => 0,
|
||||
4 => 0,
|
||||
3 => 0,
|
||||
2 => 0,
|
||||
1 => 0,
|
||||
];
|
||||
foreach ($array as $vote) {
|
||||
$_array[$vote] ++;
|
||||
}
|
||||
|
||||
$this->setData('number_of_ratings', $_array);
|
||||
}
|
||||
|
||||
private function setRatingVotes(array $rating_votes) {
|
||||
foreach ($rating_votes as $_rating_id => $_vote) {
|
||||
foreach (['percent', 'value'] as $field) {
|
||||
$_vote->setData($field, $this->getAverage($_vote->getData($field)));
|
||||
}
|
||||
}
|
||||
|
||||
$this->setData('rating_votes', $rating_votes);
|
||||
}
|
||||
|
||||
public function getReviewCount() {
|
||||
return $this->getReviewsCollection()->getSize();
|
||||
}
|
||||
|
||||
private function getReviewsItems() {
|
||||
$this->getReviewsCollection()->load()->addRateVotes();
|
||||
$_items = $this->getReviewsCollection()->getItems();
|
||||
|
||||
return $_items;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Olegnax ProductReviewsSummary
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Olegnax.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.olegnax.com/license
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Olegnax
|
||||
* @package Olegnax_ProductReviewsSummary
|
||||
* @copyright Copyright (c) 2023 Olegnax (http://www.olegnax.com/)
|
||||
* @license https://www.olegnax.com/license
|
||||
*/
|
||||
|
||||
namespace Olegnax\ProductReviewsSummary\Helper;
|
||||
|
||||
use Magento\Framework\App\Helper\AbstractHelper;
|
||||
use Magento\Store\Model\ScopeInterface;
|
||||
|
||||
class Helper extends AbstractHelper
|
||||
{
|
||||
public function getConfig($path, $storeCode = null)
|
||||
{
|
||||
return $this->getSystemValue($path, $storeCode);
|
||||
}
|
||||
|
||||
public function getSystemValue($path, $storeCode = null)
|
||||
{
|
||||
$value = $this->scopeConfig->getValue($path, ScopeInterface::SCOPE_STORE, $storeCode);
|
||||
if (is_null($value)) {
|
||||
$value = '';
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" ?>
|
||||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="urn:magento:framework:Acl/etc/acl.xsd">
|
||||
<acl>
|
||||
<resources>
|
||||
<resource id="Magento_Backend::admin">
|
||||
<resource id="Olegnax_Core::Olegnax_Core">
|
||||
<resource id="Olegnax_ProductReviewsSummary::productreviewssummary" sortOrder="10" title="Product Reviews Summary"/>
|
||||
</resource>
|
||||
</resource>
|
||||
</resources>
|
||||
</acl>
|
||||
</config>
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0"?>
|
||||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Backend:etc/menu.xsd">
|
||||
<menu>
|
||||
<add id="Olegnax_ProductReviewsSummary::productreviewssummary" title="Product Reviews Summary" translate="title" module="Olegnax_ProductReviewsSummary" sortOrder="999" parent="Olegnax_Core::Olegnax_Core" resource="Olegnax_ProductReviewsSummary::productreviewssummary"/>
|
||||
<add id="Olegnax_ProductReviewsSummary::config" title="Configuration" translate="title" module="Olegnax_ProductReviewsSummary" sortOrder="20" action="adminhtml/system_config/edit/section/olegnax_productreviewssummary" parent="Olegnax_ProductReviewsSummary::productreviewssummary" resource="Olegnax_ProductReviewsSummary::productreviewssummary"/>
|
||||
</menu>
|
||||
</config>
|
||||
@@ -0,0 +1,99 @@
|
||||
<?xml version="1.0" ?>
|
||||
<!--
|
||||
* Olegnax
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Olegnax.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.olegnax.com/license
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Olegnax
|
||||
* @package Olegnax_ProductReviewsSummary
|
||||
* @copyright Copyright (c) 2010-2021 Olegnax (http://www.olegnax.com/)
|
||||
* @license https://www.olegnax.com/license
|
||||
-->
|
||||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
|
||||
<system>
|
||||
<tab id="olegnax" translate="label" sortOrder="15">
|
||||
<label>Olegnax</label>
|
||||
</tab>
|
||||
<section id="olegnax_productreviewssummary" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="100" translate="label">
|
||||
<label>Product Reviews Summary</label>
|
||||
<tab>olegnax</tab>
|
||||
<resource>Olegnax_ProductReviewsSummary::productreviewssummary</resource>
|
||||
<group id="info" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="0" translate="label">
|
||||
<frontend_model>Olegnax\ProductReviewsSummary\Block\Adminhtml\System\Config\Form\Info</frontend_model>
|
||||
</group>
|
||||
<group id="enable_all" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="10" translate="label">
|
||||
<label>Enable</label>
|
||||
<field id="enabled" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="10" translate="label" type="select">
|
||||
<label>Enable Reviews Summary</label>
|
||||
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
|
||||
<frontend_class>on-off-trigger</frontend_class>
|
||||
</field>
|
||||
</group>
|
||||
<group id="general" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="10" translate="label">
|
||||
<label>General</label>
|
||||
<field id="rating_overall" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="10" translate="label" type="select">
|
||||
<label>Show Overall Rating Block</label>
|
||||
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
|
||||
<frontend_class>on-off-trigger</frontend_class>
|
||||
</field>
|
||||
<field id="write_btn_overall" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="12" translate="label" type="select">
|
||||
<label>Show Write a Review link in Overall Block</label>
|
||||
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
|
||||
<frontend_class>on-off-trigger</frontend_class>
|
||||
<depends>
|
||||
<field id="rating_overall">1</field>
|
||||
</depends>
|
||||
</field>
|
||||
<field id="rating_bystar_rating" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="20" translate="label" type="select">
|
||||
<label>Show Ratings by Star Block</label>
|
||||
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
|
||||
<frontend_class>on-off-trigger</frontend_class>
|
||||
</field>
|
||||
<field id="stars_text" translate="label comment" type="text" sortOrder="22" showInDefault="1" showInWebsite="1" showInStore="1">
|
||||
<label>Stars Text</label>
|
||||
<comment>Text next to the 5,4..1 star numbers in "Rating by Star" Block.</comment>
|
||||
<depends>
|
||||
<field id="rating_bystar_rating">1</field>
|
||||
</depends>
|
||||
</field>
|
||||
<field id="show_rating_percent" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="24" translate="label" type="select">
|
||||
<label>Show Percent</label>
|
||||
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
|
||||
<frontend_class>on-off-trigger</frontend_class>
|
||||
<comment>Show percent value next to each rating.</comment>
|
||||
<depends>
|
||||
<field id="rating_bystar_rating">1</field>
|
||||
</depends>
|
||||
</field>
|
||||
<field id="show_rating_count" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="26" translate="label" type="select">
|
||||
<label>Show Count</label>
|
||||
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
|
||||
<frontend_class>on-off-trigger</frontend_class>
|
||||
<comment>Show number of ratings next to each rating.</comment>
|
||||
<depends>
|
||||
<field id="rating_bystar_rating">1</field>
|
||||
</depends>
|
||||
</field>
|
||||
<field id="rating_breakdown" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="30" translate="label" type="select">
|
||||
<label>Show Rating Breakdown Block</label>
|
||||
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
|
||||
<frontend_class>on-off-trigger</frontend_class>
|
||||
</field>
|
||||
<field id="write_btn_after" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="40" translate="label" type="select">
|
||||
<label>Show Write a Review Buttton block</label>
|
||||
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
|
||||
<frontend_class>on-off-trigger</frontend_class>
|
||||
</field>
|
||||
</group>
|
||||
</section>
|
||||
</system>
|
||||
</config>
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" ?>
|
||||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
|
||||
<default>
|
||||
<olegnax_productreviewssummary>
|
||||
<enable_all>
|
||||
<enabled>1</enabled>
|
||||
</enable_all>
|
||||
<general>
|
||||
<rating_overall>1</rating_overall>
|
||||
<write_btn_overall>0</write_btn_overall>
|
||||
<rating_bystar_rating>1</rating_bystar_rating>
|
||||
<stars_text>Stars</stars_text>
|
||||
<show_rating_percent>1</show_rating_percent>
|
||||
<show_rating_count>1</show_rating_count>
|
||||
<rating_breakdown>1</rating_breakdown>
|
||||
<write_btn_after>1</write_btn_after>
|
||||
</general>
|
||||
</olegnax_productreviewssummary>
|
||||
</default>
|
||||
</config>
|
||||
@@ -0,0 +1,8 @@
|
||||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
|
||||
<module name="Olegnax_ProductReviewsSummary" setup_version="0.0.9.1">
|
||||
<sequence>
|
||||
<module name="Olegnax_Core"/>
|
||||
<module name="Magento_Review"/>
|
||||
</sequence>
|
||||
</module>
|
||||
</config>
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
use Magento\Framework\Component\ComponentRegistrar;
|
||||
|
||||
ComponentRegistrar::register(
|
||||
ComponentRegistrar::MODULE,
|
||||
'Olegnax_ProductReviewsSummary',
|
||||
__DIR__
|
||||
);
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/**
|
||||
* Olegnax
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Olegnax.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.olegnax.com/license
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Olegnax
|
||||
* @package Olegnax_ProductReviewsSummary
|
||||
* @copyright Copyright (c) 2010-2021 Olegnax (http://www.olegnax.com/)
|
||||
* @license https://www.olegnax.com/license
|
||||
*/
|
||||
-->
|
||||
<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/layout_generic.xsd">
|
||||
<container name="root">
|
||||
<block class="Magento\Review\Block\Product\View\ListView" name="product.info.product_additional_data" as="product_additional_data" template="Magento_Review::product/view/list.phtml" >
|
||||
<action method="setTemplate" ifconfig="olegnax_productreviewssummary/enable_all/enabled">
|
||||
<argument name='template' xsi:type='string'>Olegnax_ProductReviewsSummary::product/view/list.phtml</argument>
|
||||
</action>
|
||||
<block class="Olegnax\ProductReviewsSummary\Block\Html\ReviewSummary" name="product.review.summary" as="review_summary" template="Olegnax_ProductReviewsSummary::product/view/blocks/summary.phtml"/>
|
||||
<block class="Olegnax\ProductReviewsSummary\Block\Html\ReviewSummary" name="product.review.byrating" as="review_by_rating" template="Olegnax_ProductReviewsSummary::product/view/blocks/by-rating.phtml"/>
|
||||
<block class="Olegnax\ProductReviewsSummary\Block\Html\ReviewSummary" name="product.review.ratingsbreakdown" as="review_ratings_breakdown" template="Olegnax_ProductReviewsSummary::product/view/blocks/ratings-breakdown.phtml"/>
|
||||
<block class="Olegnax\ProductReviewsSummary\Block\Html\ReviewSummary" name="product.review.reviewbutton" as="review_review_button" template="Olegnax_ProductReviewsSummary::product/view/blocks/write-review-button.phtml"/>
|
||||
</block>
|
||||
</container>
|
||||
</layout>
|
||||
Executable
+51
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Olegnax ProductReviewsSummary
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Olegnax.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.olegnax.com/license
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Olegnax
|
||||
* @package Olegnax_ProductReviewsSummary
|
||||
* @copyright Copyright (c) 2023 Olegnax (http://www.olegnax.com/)
|
||||
* @license https://www.olegnax.com/license
|
||||
*/
|
||||
|
||||
$settings = $this->helper('Olegnax\ProductReviewsSummary\Helper\Helper')->getConfig('olegnax_productreviewssummary/general');
|
||||
|
||||
$enabled = $settings['rating_bystar_rating'];
|
||||
$show_rating_percent = $settings['show_rating_percent'];
|
||||
$show_rating_count = $settings['show_rating_count'];
|
||||
$star_text = $settings['stars_text'] ?: '';
|
||||
if ($enabled):?>
|
||||
<?php if (count($block->getNumberOfRatings())): ?>
|
||||
<div class="number-of-ratings">
|
||||
<?php $countRatings = array_sum($block->getNumberOfRatings()); ?>
|
||||
<?php if (0 < $countRatings) {
|
||||
foreach ($block->getNumberOfRatings() as $_vote => $_count): ?>
|
||||
<?php $percent = round($_count * 100 / $countRatings, 1); ?>
|
||||
<div class="rating-item">
|
||||
<span class="rating-number"><span class="count"><?= $block->escapeHtml($_vote) ?></span> <span
|
||||
class="label"><?= $block->escapeHtml($star_text) ?></span></span>
|
||||
<div class="rating-result"><span style="width:<?= $block->escapeHtml($percent) ?>%"></span>
|
||||
</div>
|
||||
<div class="rating-percent"><?php if ($show_rating_percent) {
|
||||
echo $block->escapeHtml($percent) . '%';
|
||||
} ?><?php if ($show_rating_count) {
|
||||
echo '(' . $block->escapeHtml($_count) . ')';
|
||||
} ?></div>
|
||||
</div>
|
||||
<?php endforeach;
|
||||
} ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Olegnax ProductReviewsSummary
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Olegnax.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.olegnax.com/license
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Olegnax
|
||||
* @package Olegnax_ProductReviewsSummary
|
||||
* @copyright Copyright (c) 2023 Olegnax (http://www.olegnax.com/)
|
||||
* @license https://www.olegnax.com/license
|
||||
*/
|
||||
$enabled = $this->helper('Olegnax\ProductReviewsSummary\Helper\Helper')->getConfig('olegnax_productreviewssummary/general/rating_breakdown');
|
||||
|
||||
if($enabled) {
|
||||
?>
|
||||
<?php if (count($block->getRatingVotes()) > 1 ): ?>
|
||||
<div class="review-ratings">
|
||||
<?php foreach ($block->getRatingVotes() as $_vote): ?>
|
||||
<div class="rating-summary item" itemprop="reviewRating" itemscope itemtype="http://schema.org/Rating">
|
||||
<span class="label rating-label"><span><?= $block->escapeHtml($_vote->getRatingCode()) ?></span></span>
|
||||
<div class="rating-result" title="<?= $block->escapeHtmlAttr($_vote->getPercent()) ?>%">
|
||||
<meta itemprop="worstRating" content = "1"/>
|
||||
<meta itemprop="bestRating" content = "100"/>
|
||||
<span style="width:<?= $block->escapeHtmlAttr($_vote->getPercent()) ?>%">
|
||||
<span itemprop="ratingValue"><?= $block->escapeHtml($_vote->getPercent()) ?>%</span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php } ?>
|
||||
Executable
+46
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Olegnax ProductReviewsSummary
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Olegnax.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.olegnax.com/license
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Olegnax
|
||||
* @package Olegnax_ProductReviewsSummary
|
||||
* @copyright Copyright (c) 2023 Olegnax (http://www.olegnax.com/)
|
||||
* @license https://www.olegnax.com/license
|
||||
*/
|
||||
|
||||
$settings = $this->helper('Olegnax\ProductReviewsSummary\Helper\Helper')->getConfig('olegnax_productreviewssummary/general');
|
||||
|
||||
$enabled = $settings['rating_overall'];
|
||||
$button = $settings['write_btn_overall'];
|
||||
if($enabled) {
|
||||
?>
|
||||
<div class="extended-review-summary">
|
||||
<div class="ratings-value"><?= number_format($block->getAverageRating(),1) ?></div>
|
||||
<div class="ratings-count">
|
||||
<span class="label"><?= $block->getReviewCount() ?> <?= $block->escapeHtml(__('Reviews')) ?></span>
|
||||
<?php $block->getRatingVotes(); ?>
|
||||
<div class="rating-result" title="<?= $block->escapeHtmlAttr($block->getPercent()) ?>%">
|
||||
<meta itemprop="worstRating" content="1">
|
||||
<meta itemprop="bestRating" content="100">
|
||||
<span style="width:<?= $block->escapeHtmlAttr($block->getPercent()) ?>%">
|
||||
<span itemprop="ratingValue"><?= $block->escapeHtmlAttr($block->getPercent()) ?>%</span>
|
||||
</span>
|
||||
</div>
|
||||
<?php if( $button ){ ?>
|
||||
<a href="#review-form" class="action write-review"><?= $block->escapeHtml(__('Write a Review')) ?></a>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Olegnax ProductReviewsSummary
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Olegnax.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.olegnax.com/license
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Olegnax
|
||||
* @package Olegnax_ProductReviewsSummary
|
||||
* @copyright Copyright (c) 2023 Olegnax (http://www.olegnax.com/)
|
||||
* @license https://www.olegnax.com/license
|
||||
*/
|
||||
|
||||
$show_button = $this->helper('Olegnax\ProductReviewsSummary\Helper\Helper')->getConfig('olegnax_productreviewssummary/general/write_btn_after');
|
||||
if($show_button) :
|
||||
?>
|
||||
<div class="extended-review-button">
|
||||
<a href="#review-form" class="action primary"><span><?= $block->escapeHtml(__('Write a Review')) ?></span></a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
+102
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
/**
|
||||
* Olegnax ProductReviewsSummary
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Olegnax.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.olegnax.com/license
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Olegnax
|
||||
* @package Olegnax_ProductReviewsSummary
|
||||
* @copyright Copyright (c) 2023 Olegnax (http://www.olegnax.com/)
|
||||
* @license https://www.olegnax.com/license
|
||||
*/
|
||||
|
||||
// @codingStandardsIgnoreFile
|
||||
|
||||
/** @var Magento\Review\Block\Product\View\ListView $block */
|
||||
/** @var SecureHtmlRenderer $secureRenderer */
|
||||
|
||||
use Magento\Framework\View\Helper\SecureHtmlRenderer;
|
||||
|
||||
$_items = $block->getReviewsCollection()->getItems();
|
||||
$format = $block->getDateFormat() ?: \IntlDateFormatter::SHORT;
|
||||
|
||||
$settings = $this->helper('Olegnax\ProductReviewsSummary\Helper\Helper')->getConfig('olegnax_productreviewssummary/general');
|
||||
$summaryBlocksCount = 0;
|
||||
$summaryBlocksCount += $settings['rating_bystar_rating'];
|
||||
$summaryBlocksCount += $settings['rating_overall'];
|
||||
$summaryBlocksCount += $settings['write_btn_after'];
|
||||
$summaryBlocksCount += $settings['rating_breakdown'];
|
||||
?>
|
||||
<?php if (count($_items)):?>
|
||||
<div class="block review-list" id="customer-reviews">
|
||||
<div class="block-title">
|
||||
<strong><?= $block->escapeHtml(__('Customer Reviews')) ?></strong>
|
||||
</div>
|
||||
<div class="block-content">
|
||||
<div class="extended-review-summary-wrapper columns-<?= $summaryBlocksCount ?>">
|
||||
<?= $block->getChildHtml('review_summary'); ?>
|
||||
<?= $block->getChildHtml('review_by_rating'); ?>
|
||||
<?= $block->getChildHtml('review_ratings_breakdown'); ?>
|
||||
<?= $block->getChildHtml('review_review_button'); ?>
|
||||
</div>
|
||||
<div class="toolbar review-toolbar">
|
||||
<?= $block->getChildHtml('toolbar') ?>
|
||||
</div>
|
||||
<ol class="items review-items">
|
||||
<?php foreach ($_items as $_review):?>
|
||||
<li class="item review-item" itemscope itemprop="review" itemtype="http://schema.org/Review">
|
||||
<div class="review-title" itemprop="name"><?= $block->escapeHtml($_review->getTitle()) ?></div>
|
||||
<?php if (count($_review->getRatingVotes())): ?>
|
||||
<div class="review-ratings">
|
||||
<?php foreach ($_review->getRatingVotes() as $_vote): ?>
|
||||
<div class="rating-summary item" itemprop="reviewRating" itemscope itemtype="http://schema.org/Rating">
|
||||
<span class="label rating-label"><span><?= $block->escapeHtml($_vote->getRatingCode()) ?></span></span>
|
||||
<div class="rating-result"
|
||||
id="review_<?= /* @noEscape */ $_review->getReviewId()
|
||||
?>_vote_<?= /* @noEscape */ $_vote->getVoteId() ?>"
|
||||
title="<?= $block->escapeHtmlAttr($_vote->getPercent()) ?>%">
|
||||
<meta itemprop="worstRating" content = "1"/>
|
||||
<meta itemprop="bestRating" content = "100"/>
|
||||
<span>
|
||||
<span itemprop="ratingValue"><?= $block->escapeHtml($_vote->getPercent()) ?>%</span>
|
||||
</span>
|
||||
</div>
|
||||
<?= /* @noEscape */ $secureRenderer->renderStyleAsTag(
|
||||
'width:' . $_vote->getPercent() . '%',
|
||||
'div#review_' . $_review->getReviewId() . '_vote_' . $_vote->getVoteId() . ' span'
|
||||
) ?>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="review-content" itemprop="description">
|
||||
<?= nl2br($block->escapeHtml($_review->getDetail())) ?>
|
||||
</div>
|
||||
<div class="review-details">
|
||||
<p class="review-author">
|
||||
<span class="review-details-label"><?= $block->escapeHtml(__('Review by')) ?></span>
|
||||
<strong class="review-details-value" itemprop="author"><?= $block->escapeHtml($_review->getNickname()) ?></strong>
|
||||
</p>
|
||||
<p class="review-date">
|
||||
<span class="review-details-label"><?= $block->escapeHtml(__('Posted on')) ?></span>
|
||||
<time class="review-details-value" itemprop="datePublished" datetime="<?= $block->escapeHtmlAttr($block->formatDate($_review->getCreatedAt(), $format)) ?>"><?= $block->escapeHtml($block->formatDate($_review->getCreatedAt(), $format)) ?></time>
|
||||
</p>
|
||||
</div>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ol>
|
||||
<div class="toolbar review-toolbar">
|
||||
<?= $block->getChildHtml('toolbar') ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif;?>
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
& when (@media-common = true) {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user