1

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

4

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).

  • Note that there are different directories for templates, web/template for HTML templates. And Vendor_Module/templates for PHTML files. – Ben Crook Mar 8 '18 at 17:21
  • That's great thanks! I had tried this path before but did not do the php bin/magento setup:upgrade after. Great note there. – Leon Mar 8 '18 at 17:33
  • Leon & Ben Crook: Thank you so much, actually I override but not did setup:upgrade. – Pratik Mehta Oct 25 '18 at 5:50

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.