0

In Magento 2 product page I need to add a link beside the Size attribute, should show as below image.

which xml and phtml file to edit?

enter image description here

  • Are you using parent theme as luma? – Sukumar Gorai Jul 9 '18 at 8:45
  • i'm using custom theme – Ahmad Darwish Jul 9 '18 at 8:59
-1

There are several ways to do this, one of the easiest way is to create .phtml file and put all the contents or create block and get data from database into the phtml. Location of your .phtml can either be inside your extention view/frontend/template/product/view/* folder or inside your theme in the same hierarchy.

Once done, then in your theme/extension layout catalog_product_view.xml layout file, you can inject your block and phtml file

<referenceContainer name="yourconteinername">
            <block class="YourbockClass" name="product_view_link" after="-" template="YourModule::product/view/yourtemplatefile.phtml"/>
        </referenceContainer>

also you can use move needle in the layout xml to show this block whereever you may want

<move element="yourconteinername" destination="product.info.main" before="-"/>
  • i've every info created and i'm able to show the link just below the add-to-cart button, i need to show it just next to size attribute title – Ahmad Darwish Jul 9 '18 at 9:01
  • but you can use the <move as i mentioned above and in the destination you can add product.info and instead of the before tag you can use the after tag with value of your product.options – Zeeshan Khuwaja Jul 9 '18 at 9:09
  • This will put it after or before the the product info option but not within the options area, I want it exactly next to Size, can we chat about this, room: chat.stackexchange.com/rooms/79919/… – Ahmad Darwish Jul 9 '18 at 9:30

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.