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 Answer 1

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

12
  • 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? Jul 11, 2018 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. Jul 11, 2018 at 9:19
  • Is it working fine? Jul 11, 2018 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? Jul 11, 2018 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. Jul 11, 2018 at 10:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.