Magento 2 Tutorials

How to Edit Recently Viewed Products Price Position in Magento 2?

1 Star2 Stars3 Stars4 Stars5 Stars (2 votes, average: 5.00 out of 5)
Loading...Loading...
How to Edit Recently Viewed Products Price Position in Magento 2

In today’s tutorial, we will guide you through a step-by-step guide to edit Recently Viewed Products Price Position in Magento 2. Follow these steps to easily edit Recently Viewed Products Price Position. 

Step 1 – Login to Admin Panel

Step 2 – Navigate to Content → Block

Step 3 – Create new product-detail block and edit then toggle show/hide editor which will show insert widget option

Step 4 – Click on insert widget select “Recently Viewed Products” from dropdown, add number of product to display (ex – 8)

Step 5 – Select template from dropdown then click on insert widget

Step 6 – Click on save Block

If this gets confusing, the below code works well in home-page block:

<p>{{widget type="Magento\Catalog\Block\Widget\RecentlyViewed" uiComponent="widget_recently_viewed" page_size="8" show_attributes="name,image,price" show_buttons="add_to_cart" template="product/widget/viewed/grid.phtml"}}</p>

There is an another approach to this process as well. We can do it programmatically too. Let us take a look into it:

Add below code in vendor/magento/theme-frontend-luma/Magento_Catalog/layout/catalog_product_view

<block class="Magento\Reports\Block\Product\Widget\Viewed" after="-" name="recently_viewed" cacheable="false" template="Magento_Reports::widget/viewed/content/viewed_grid.phtml">
<action method="setPageSize">
    <argument name="page_size" xsi:type="number">8</argument>
</action>

Here is the final code for catalog_product_view

<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <move element="page.main.title" destination="product.info.main" before="-"/>
        <move element="product.info.stock.sku" destination="product.info.price" after="product.price.final"/>
        <move element="product.info.review" destination="product.info.main" before="product.info.price"/>

         <block class="Magento\Reports\Block\Product\Widget\Viewed" after="-" name="recently_viewed" cacheable="false" template="Magento_Reports::widget/viewed/content/viewed_grid.phtml">
            <action method="setPageSize">
                <argument name="page_size" xsi:type="number">8</argument>
            </action>
        </block>
    </body>
</page>

And here you go! We hope we’ve cleared the process of editing the price position of recently viewed products in Magento 2. If you face any issue while implementation, feel free to reach us out.

You may also like
How to Add Products to Multiple Categories Programmatically in Magento 2
How to Add Products to Multiple Categories Programmatically in Magento 2?
Store Pickup Functionality in Magento 2
Guide to Setup Pickup Functionality in Magento 2 Store

Leave Your Comment

Your Comment*

Your Name*