In magento2,using custom modules i need to show customer review in separate page like
- reviewer name,
- rating given
- Which Product customer gave rating? etc.
Let me know how to get all those details in custom page.
You have call review collection class \Magento\Review\Model\ResourceModel\Review\Product\CollectionFactory
at your custom page's block class.
Inject this class at __construct().
Block Class
/**
* Product reviews collection
*
* @var \Magento\Review\Model\ResourceModel\Review\Product\Collection
*/
protected $_collection;
/**
* Review resource model
*
* @var \Magento\Review\Model\ResourceModel\Review\Product\CollectionFactory
*/
protected $_collectionFactory;
public function __construct(
.....
\Magento\Review\Model\ResourceModel\Review\Product\CollectionFactory $collectionFactory,
.................
) {
.......
$this->_collectionFactory = $collectionFactory;
.......
}
/**
* Get reviews
*
* @return bool|\Magento\Review\Model\ResourceModel\Review\Product\Collection
*/
public function getReviews()
{
if (!$this->_collection) {
$this->_collection = $this->_collectionFactory->create();
$this->_collection
->addStoreFilter($this->_storeManager->getStore()->getId())
->setDateOrder();
$this->_collection->addReviewSummary()
}
return $this->_collection;
}