Question

Magento 2 how to get the data from 'rating_option_vote' by review_id using objectmanager?

Was it helpful?

Solution

You can use 'Magento\Review\Model\ResourceModel\Rating\Option\Vote\Collection'. Find the code for getting the collection and filtering it by 'review_id'.

<?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());
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top