How to add a custom link to product page magento 2

Magento Asked on January 6, 2022

I want to add custom link in More Information tab.
See attached screenshot:

I want to give a link instead of text

enter image description here

3 Answers

I was able to do this by adding the attribute then importing via csv with text similar to the following

'<a href='' target='_blank'></a>

It will also work if directly entered in the new product attribute.

Answered by user10588486 on January 6, 2022

  • Create an Attribute in admin with text type say external_link

  • Add phtml at:


<page xmlns:xsi="" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <referenceBlock name="">
            <block class="MagentoCatalogBlockProductView" name="" template="Magento_Catalog::externallink.phtml"/>

Now create phtml and get attribute value:


<?php $product = $block->getProduct(); ?>
<?php if($link = $product->getExternalLink()){ ?>
    <div class="link">
        <a href="<?= $link; ?>"><?= $block->escapeHtml(__('Link text')) ?></a>
<?php } ?>

Hope above will help!

Answered by Pawan on January 6, 2022

Then you need to do the following things.

  1. first create one product attribute where you mention this link of third party.

  2. Now create one custom extension and create custom phtml file and call the file on product page on specific by using reference block.

  3. Now in that phtml file, fetch that product attribute value and show to customer.

Answered by Dhiren Vasoya on January 6, 2022

Add your own answers!

Related Questions

Watermark Category Images with Brand Logo

1  Asked on February 26, 2021 by ijeep


Issue With Displaying Gallery Widget

1  Asked on February 24, 2021 by magento_learner


Same email different customer

0  Asked on February 21, 2021 by aivdev


Cron job is running but not updating Inventory

0  Asked on February 20, 2021 by anonymous-record


Sending variable to a bootstrap modal

1  Asked on February 19, 2021 by jayreis


No varnish headers

2  Asked on February 17, 2021 by maciej


Ask a Question

Get help from others!

© 2023 All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP