2

I want to get product rating details based on product id. can you anyone help me how to get details programmatically in Magento 2.

2

Below code may help you.

$_productID = 101;
$_product=$this->_objectManager->create("Magento\Catalog\Model\Product")->load($_productID);
$_review=$this->_objectManager->create("Magento\Review\Model\Review");
$_reviewFact=$this->_objectManager->get("Magento\Review\Model\ReviewFactory");
$_reviewFact->create()->getEntitySummary($_product, 1);  
//Below code will get the rating summary
print_r($_product->getRatingSummary()->getRatingSummary());
1
  • please help me to get the reviews.The above code returns the rating percentage of products only.
    – srg
    Aug 17 '17 at 5:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.