Question

I want to override recently viewed template that is currently located in

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

catalog_product_view.xml

        <block class="Magento\Catalog\Block\Widget\RecentlyViewed" name="pdp.recently-viewed" template="Magento_Catalog::product/widget/viewed/grid.phtml" after="pdp.recommended-items">
           <arguments> 
              <argument name="uiComponent" xsi:type="string">widget_recently_viewed</argument> 
              <argument name="page_size" xsi:type="number">10</argument> 
              <argument name="show_attributes" xsi:type="string">image,name,price</argument>
           </arguments> 
        </block>

</referenceContainer>

The template file points to

grid.phtml

<?php
/**
 * @var $block \Magento\Ui\Block\Wrapper
 */
?>
<?= /* @escapeNotVerified */ $block->renderApp([
    'widget_columns' => [
        'displayMode' => 'grid'
    ],
    'image' => [
        'imageCode' => 'recently_viewed_products_grid_content_widget'
    ]
]);

Which then renders on the frontend later from the file I said above.

listing.html

<div if="hasData()"
     class="block" css="additionalClasses">
    <div class="block-title">
        <strong role="heading"
                aria-level="2"
                text="label"/>
    </div>
    <div class="block-content">
        <div css="'products-' + displayMode">
            <ol class="product-items">
              ...

            </ol>
        </div>
    </div>

What do I need to do to override this template?

I have tried creating a file at:

app/design/frontend/Vendor/theme/Magento_Catalog/templates/product/list/listing.html

Was it helpful?

Solution

You have added it to the wrong directory, try this instead:

app/design/frontend/Vendor/theme/Magento_Catalog/web/template/product/list/listing.html

Then recompile following your usual workflow (grunt/gulp/static content deploy).

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top