1

I have created a Recently Viewed Products widget and in the widget option I can select what is shown for every product, attributes and buttons.

In the attributes there is an option of a Learn More Link which is not selected. However in the Recently viewed products, there is a Learn More link.

How could I remove it?

1

If you check the following file:

vendor/magento/module-reports/view/frontend/templates/widget/viewed/content/viewed_list.phtml

You will find the following code:

$description = ($mode == 'list') ? true : false;

also check the following code which renders the Learn more link:

<?php if ($description):?>
    <div class="product-item-description">
        <?= /* @escapeNotVerified */ $_helper->productAttribute($_item, $_item->getShortDescription(), 'short_description') ?>
        <a title="<?= $block->escapeHtml($_item->getName()) ?>"
           href="<?= /* @escapeNotVerified */ $block->getProductUrl($_item) ?>"
           class="action more"><?= /* @escapeNotVerified */ __('Learn More') ?></a>
    </div>
<?php endif; ?>

Which means on list mode learn more always visible. You need to change the logic there but copy the file to your theme location like below:

app/design/frontend/[Vendor]/[Theme]/Magento_Reports/templates/widget/viewed/content/viewed_list.phtml

  • List mode you mean how the products are viewed? The options were Grid and List which I used both , with Learn more link un-selected. And the link was visible both time. If I delete that <a> with the Learn more string, would I be ok? – SUPERDEVELOPER Jul 11 '18 at 9:17
  • There are 2 types of view in magento one is list view and another one is grid view. Learn more button always shows for list view. you can either change the line $description = ($mode == 'list') ? false : false; to false : false for both then Learn more button will be removed for both views Or you can remove it from the code. – Sukumar Gorai Jul 11 '18 at 9:19
  • Is it working fine? – Sukumar Gorai Jul 11 '18 at 9:38
  • I want to use grid view for this purpose. However there is no mention of grid in the viewed_list.phtml file. Should I add code about grid view? Or delete the Learn more link all together? – SUPERDEVELOPER Jul 11 '18 at 10:42
  • Yes because there is a file in the same path called viewed_grid.phtml which is used for grid view. You can delete that link from code. – Sukumar Gorai Jul 11 '18 at 10:43

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.