cancel
Showing results for 
Search instead for 
Did you mean: 

How can i edit recently viewed products widget layout?

SOLVED

How can i edit recently viewed products widget layout?

I want to edit recently viewed products widget layout and override on my custom theme, but i can't reach to layout template under /vendor/magento/module-catalog/view/frontend/templates/product/widget/viewed/grid.phtml.
<?php/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
?>
<?php/**
 * @var $block \Magento\Ui\Block\Wrapper
 */
?>

<?= /* @escapeNotVerified */ $block->renderApp([
    'widget_columns' => [
        'displayMode' => 'grid'
    ],
    'image' => [
        'imageCode' => 'recently_viewed_products_grid_content_widget'
    ]
]);

I edited before new products widget layout. How can i do with same way?

Which file need i to copy under my template folder?

6 REPLIES

Re: How can i edit recently viewed products widget layout?

For Product widget defined under Catalog Module. You can find below file for recently viewed product widget layout at widget.xml file.

 

File Path,

vendor/magento/module-catalog/etc/widget.xml

 

In above layout file,

Code for Recently viewed product phtml defined as,

<option name="grid" value="product/widget/viewed/grid.phtml" selected="true">
       <label translate="true">Viewed Products Grid Template</label>
</option>

There are no other layout defined for recently viewed layout so if you want to modify template file you can modify from

grid.phtml

of above-declared template.

If Issue Solved, Click Kudos/Accept As solutions.

Re: How can i edit recently viewed products widget layout?

Hello @Ylmzef

 

 

Based on magento stadard you can not change vendor file.

 

you can do two way 

1) Create module and change template file as suggest @Rakesh Jesadiya

2) After add widget into cms page or static block, you need to change that template file path to your path and save it that block and page.

 

I think 2 option is good, without create module.

 

If it will work then mark as solution.

Re: How can i edit recently viewed products widget layout?

<?= /* @escapeNotVerified */ $block->renderApp([
'widget_columns' => [
'displayMode' => 'grid'
],
'image' => [
'imageCode' => 'recently_viewed_products_grid_content_widget'
]
]);

 

How can i edit this layout? It's grid.phtml of the widget.

Re: How can i edit recently viewed products widget layout?

Hello @Ylmzef

 

{{widget type="Magento\Catalog\Block\Widget\RecentlyViewed" uiComponent="widget_recently_viewed" page_size="5" show_attributes="name,image,price,learn_more" show_buttons="add_to_cart,add_to_compare,add_to_wishlist" template="product/widget/viewed/list.phtml"}}

After add widget into page it will show above code, you need to manually edit that template file

e.g

{{widget type="Magento\Catalog\Block\Widget\RecentlyViewed" uiComponent="widget_recently_viewed" page_size="5" show_attributes="name,image,price,learn_more" show_buttons="add_to_cart,add_to_compare,add_to_wishlist" template="product/widget/viewed/list2.phtml"}}

Save it Smiley Happy

 

If it will work then mark as solution.

Re: How can i edit recently viewed products widget layout?

thanks but the default phtml file of widget doesnt content any html content.

How can i edit it?

How can i call products/values etc?

Re: How can i edit recently viewed products widget layout?

Hello @Ylmzef

 

sorry for wrong reply.

 

I did debug more about this and it is coming from KO 

 

vendor\magento\module-catalog\view\frontend\ui_component\widget_recently_viewed.xml

 

<columns name="widget_columns" component="Magento_Catalog/js/product/list/listing" template="Magento_Catalog/product/list/listing">

from above code it is calling one template file

 

vendor\magento\module-catalog\view\base\web\template\product\list\listing.html

 

 

so you need to copy same folder structure into your theme and you need to change it.

 

 

you need to do static content deploy as well.

 

If it will help you then mark as solution.