0

I extended Magento_Catalog in a custom theme and added the following block:

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="product.info.main">
            <block class="Magento\Framework\View\Element\Template" name="lvluplink" after="product.info.price" template="Magento_Catalog::customline.phtml" />
        </referenceContainer>
    </body>
</page>

the template:

<a class="primary action" href="https://google.com"><?= __('Custom Button') ?></a>

The link shows up in the store, but clicking the link does nothing. I am running Magento 2.3.4 in developer mode and have run:

bin/magento setup:upgrade
bin/magento setup:di:compile
bin/magento setup:static-content:deploy -f
bin/magento cache:clean
bin/magento cache:flush
0

Try this code

1.app/design/frontend/Mage/Mohit/Magento_Catalog/templates/product/customline.phtml

<a class="primary action" href="https://google.com"><?= __('Custom Button') ?></a>

2.app/design/frontend/Mage/Mohit/Magento_Catalog/layout/catalog_product_view.xml

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="product.info.main">
            <block class="Magento\Framework\View\Element\Template" name="lvluplink" after="product.info.price" template="Magento_Catalog::product/customline.phtml" />
        </referenceContainer>
    </body>
</page>

And after run the php bin/magento c:f

Output :-

enter image description here

And click button working fine.

Hope this help you

Thanks ...

  • So, move the template into the directory product? – Lunchbox Apr 27 '20 at 13:25
  • It turns out that having developer hints on precludes clicking any buttons or links. – Lunchbox Apr 27 '20 at 13:39
  • what you say i don't understand . so please explain me ... – Mohit Patel Apr 27 '20 at 14:27
  • I had the front end developer hints on. The hints stop the user from clicking on links/buttons. – Lunchbox Apr 27 '20 at 16:37
  • you go to admin panel disable the developer debug hints ... – Mohit Patel Apr 27 '20 at 17:19
0

I had developer hints on. This prevents any links or buttons from being clicked on the page. Turned off the hints and the link works as expected.

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.