If you have add product review and rating and approved admin side. After you have seen on recently view product.
-
which page ????– Ronak RathodCommented Sep 23, 2019 at 12:24
-
@RkRathod homepage– ann karsksyaCommented Sep 23, 2019 at 12:25
-
magento.stackexchange.com/questions/226162/…– Ronak RathodCommented Sep 23, 2019 at 12:28
-
@RkRathod in no example, dependencies for the code to work, as well as where to enter it– ann karsksyaCommented Sep 23, 2019 at 12:33
-
you want to disaply recent view product programatically on home page Right??– Ronak RathodCommented Sep 23, 2019 at 12:38
|
Show 1 more comment
1 Answer
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 Commented Sep 23, 2019 at 12:51
-
this code for programatically add widget on home page. Commented Sep 23, 2019 at 12:58