0

I have made a widget to get reviews of all products on a single page. but not be able to show rating stars and products details with that. I tried many solutions but nothing works

<?php
    $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
    $_reviewsColFactory = $objectManager->get("\Magento\Review\Model\ResourceModel\Review\CollectionFactory");
    $_storeManager = $objectManager->get('\Magento\Store\Model\StoreManagerInterface');
    $reviewsCollection = $_reviewsColFactory->create()
                                            ->addStoreFilter($_storeManager->getStore()->getStoreId())
                                            ->addStatusFilter(\Magento\Review\Model\Review::STATUS_APPROVED)
                                            ->setDateOrder();

    foreach($reviewsCollection as $review):?>
        <div class='review-single'>
            <div class="box-review-single">
                <h3> <?php echo $review['nickname'];?></h3>
                <br>
                <h4 class="title-review"><?php echo $review['title'];?></h4>
                <br>
                <p class="detail-review"><?php echo $review['detail'];?></p>
            </div>
            <hr>
        </div>
    <?php endforeach; ?>

Your Answer

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

Browse other questions tagged or ask your own question.