At the bottom of the page I have created a custom module in that I want to call getReviewsCollection()
function to display information of reviews?
Can anyone please help me?
Bottom of the page custom module is displayed.
I have used https://github.com/MauroNigrele/magento2-test-modules/tree/master/Test/Catalog/view/frontend to create custom module.
Test/Review/registration.php
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'Test_Review',
__DIR__
);
Test/Review/etc/module.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Test_Review" setup_version="1.0.0">
<sequence>
<module name="Magento_Catalog"/>
<module name="Magento_Review"/>
</sequence>
</module>
</config>
Test/Review/Block/Product/View/Extra.php
<?php
namespace Test\Review\Block\Product\View;
use Magento\Catalog\Block\Product\AbstractProduct;
class Extra extends AbstractProduct
{
}
Test/Review/view/frontend/templates/product/view/extra.phtml
<?php /* @var $block \Test\Catalog\Block\Product\View\Extra */?>
<?php $_product = $block->getProduct() ?>
<h3><?php echo 'My Product Name Is: ' . $_product->getName(); ?></h3>
Test/Review/view/frontend/layout/catalog_product_view.xml
<?xml version="1.0"?>
<body>
<referenceContainer name="product.info.social">
<block class="Test\Review\Block\Product\View\Extra"
name="product.view.extra"
template="Test_Review::product/view/extra.phtml"
after="-">
</block>
</referenceContainer>
</body>