0

How to display Review form in any where in product page using new .phtml file?

  • You need to tell us exact place – Ravi Soni Jul 3 at 6:04
  • yes , as i am creating configurable product page with first remove all and make one configurable.phtml file in my theme so i need to display that any where that only review form. – sarvesh Dineshkumar Patel Jul 3 at 6:07
  • Do you mean your custom configurable product page? – Ravi Soni Jul 3 at 7:06
  • yes i created for my self so anyway i will display. thanks sir – sarvesh Dineshkumar Patel Jul 3 at 7:20
  • Okay, can you please add here your layout xml code here. – Ravi Soni Jul 3 at 7:21
0

Please call Review-Form file Inside catalog_product_view.xml

\app\design\frontend\CustomVendor\theme-custom\Magento_Catalog\layout\catalog_product_view.xml

<block class="Magento\Review\Block\Form" name="product.review.form" as="review_form">
    <block class="Magento\Framework\View\Element\FormKey" name="formkey"/>
    <container name="product.review.form.fields.before" as="form_fields_before" label="Review Form Fields Before"/>
</block>
0

in list page you can use

if ($block->getMode() == 'grid') {
        $viewMode = 'grid';
        $image = 'category_page_grid';
        $showDescription = false;
        $templateType = \Magento\Catalog\Block\Product\ReviewRendererInterface::SHORT_VIEW;
    } else {
        $viewMode = 'list';
        $image = 'category_page_list';
        $showDescription = true;
        $templateType = \Magento\Catalog\Block\Product\ReviewRendererInterface::FULL_VIEW;
    }

<?php echo $block->getReviewsSummaryHtml($_product, $templateType); ?>

And Product Detail page You can use

echo $this->getLayout()->createBlock("Magento\Catalog\Block\Product\View")->setTemplate("Magento_Catalog::product/view/review.phtml")->toHtml();
0
<?xml version="1.0"?><page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body><referenceContainer name="content">
        <block  class="Magento\Catalog\Block\Product\View\Type\Simple" name="college" template="Magento_Catalog::product/view/type/configurable.phtml" />
    </referenceContainer>
</body></page>
0

Please try below code:

Replace your code with my code

<?xml version="1.0"?><page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="content">
            <block  class="Magento\Catalog\Block\Product\View\Type\Simple" name="college" template="Magento_Catalog::product/view/type/configurable.phtml">
                <block class="Magento\Review\Block\Form" name="product.review.form" as="review_form">
                    <block class="Magento\Framework\View\Element\FormKey" name="formkey"/>
                    <container name="product.review.form.fields.before" as="form_fields_before" label="Review Form Fields Before"/>
                </block>
            </block>
        </referenceContainer>
    </body>
</page>

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.