0

If you have add product review and rating and approved admin side. After you have seen on recently view product.

0

Add cms_index_index.xml in vendor/module/view/frontend/layout/cms_index_index.xml

then add the following code to the xml

<?xml version="1.0"?>                                                     
 <page 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\Framework\View\Element\Template" name="test" template="vendor_module::home_page.phtml"></block>
    </referenceContainer>
</body>

Create home_page.phtml on vendor/module/view/frontend/templates/home_page.phtml

then add the following code to the phtml

<?php echo $this->getLayout()
            ->createBlock("Magento\Reports\Block\Product\Widget\Viewed")
            ->setDisplayType("recently.view.products")
            ->setProductsCount("6")
            ->setTemplate("widget/viewed/content/viewed_list.phtml")
            ->toHtml(); 
 ?>
  • but it can be done via cms block, but programmatically? my patches render the page in blocks so that the client could swap the page – ann karsksya Sep 23 at 12:51
  • this code for programatically add widget on home page. – Rk Rathod Sep 23 at 12:58

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.