Skip to content

Commit

Permalink
#18192, Fixed rating issue website wise
Browse files Browse the repository at this point in the history
  • Loading branch information
saphal committed Oct 27, 2018
1 parent 8ea303b commit cd24396
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion app/code/Magento/Review/Model/ResourceModel/Rating.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,18 @@ class Rating extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
*/
protected $_logger;

/**
* @var \Magento\Framework\App\State
*/
protected $_state;

/**
* @param \Magento\Framework\Model\ResourceModel\Db\Context $context
* @param \Psr\Log\LoggerInterface $logger
* @param \Magento\Framework\Module\Manager $moduleManager
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Review\Model\ResourceModel\Review\Summary $reviewSummary
* @param \Magento\Framework\App\State
* @param string $connectionName
*/
public function __construct(
Expand All @@ -48,12 +54,14 @@ public function __construct(
\Magento\Framework\Module\Manager $moduleManager,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Review\Model\ResourceModel\Review\Summary $reviewSummary,
\Magento\Framework\App\State $state,
$connectionName = null
) {
$this->moduleManager = $moduleManager;
$this->_storeManager = $storeManager;
$this->_logger = $logger;
$this->_reviewSummary = $reviewSummary;
$this->_state = $state;
parent::__construct($context, $connectionName);
}

Expand Down Expand Up @@ -425,9 +433,15 @@ public function getReviewSummary($object, $onlyForCurrentStore = true)

$data = $connection->fetchAll($select, [':review_id' => $object->getReviewId()]);

if ($this->_state->getAreaCode() == "adminhtml") {
$currentStore = false;
} else {
$currentStore = $this->_storeManager->getStore()->setId();
}

if ($onlyForCurrentStore) {
foreach ($data as $row) {
if ($row['store_id'] == $this->_storeManager->getStore()->getId()) {
if ($row['store_id'] == $currentStore) {
$object->addData($row);
}
}
Expand Down

0 comments on commit cd24396

Please sign in to comment.