You can try this
protected $_reviewFactory; public function __construct( ... \Magento\Review\Model\ReviewFactory $reviewFactory, ... ) { ... $this->_reviewFactory = $reviewFactory; ... } public function getRatingSummary() { ... $this->_reviewFactory->create()->getEntitySummary($product, $this->_storeManager->getStore()->getId()); $ratingSummary = $product->getRatingSummary()->getRatingSummary(); return $ratingSummary; }
Or you can get $reviewFactory via ObjectManager (not the best solution)
$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $reviewFactory = $objectManager->create('Magento\Review\Model\Review'); $storeId = $this->_storeManager->getStore()->getId(); $reviewFactory->getEntitySummary($product, $storeId); $ratingSummary = $product->getRatingSummary()->getRatingSummary();
hope this helps others as well