Magento 2: -How to get product reviews, each review with a star
Try to use bellow code in your phtml file You should not use the ObjectManager directly!
<?php
$productId = 'your_product_id';
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$reviewFactory = $objectManager->create('Magento\Review\Model\Review');
$product = $objectManager->create('Magento\Catalog\Model\Product')->load($productId);
$storeManager = $objectManager->create('\Magento\Store\Model\StoreManagerInterface');
$storeId = $storeManager->getStore()->getStoreId();
$reviewFactory->getEntitySummary($product, $storeId);
$ratingSummary = $product->getRatingSummary()->getRatingSummary();
$reviewCount = $product->getRatingSummary()->getReviewsCount();
?>
<?php if($ratingSummary){ ?>
<div class="product-reviews-summary short">
<div class="rating-summary">
<div title="<?php echo (int)$ratingSummary; ?>%" class="rating-result">
<span style="width:<?php echo (int)$ratingSummary; ?>%"><span><?php echo (int)$ratingSummary; ?>%</span></span>
</div>
</div>
<div class="reviews-actions">
<?php echo __('('.$reviewCount.') Reviews'); ?>
</div>
</div>
<?php } ?>
I found one link that helps to get a collection of each review
<?php
use Magento\Framework\App\Bootstrap;
require __DIR__ . '/app/bootstrap.php';
$bootstrap = Bootstrap::create(BP, $_SERVER);
$obj = $bootstrap->getObjectManager();
$state = $obj->get('Magento\Framework\App\State');
$state->setAreaCode('frontend');
$reviewId = 5; //custom review id.
$ratingCollection = $obj->get('Magento\Review\Model\ResourceModel\Rating\Option\Vote\Collection')
->addRatingInfo()
->addOptionInfo()
->addRatingOptions()
->addFieldToFilter('review_id',$reviewId);
print_r($ratingCollection->getData());