QuestionsAdd Social Sharing Links in Magento 2
mmWebetutorial Staff asked 6 months ago

You should notice that the layout file responsible for rendering is:

<Magento_Catalog_module_dir>/view/frontend/layout/catalog_product_view.xml

And to override this layout file, we need to copy the file to the following location in the child theme:

<child_theme_dir>/Magento_Catalog/layout/catalog_product_view.xml

Now, in this file, locate the product.info.social container.

This container is responsible for rendering the ‘Add to Wish List’ and ‘Add to Compare’ buttons. Add a new block as shown in the snippet below to render the social icons:

<container name=”product.info.social” label=”social links” htmlTag=”div” htmlClass=”product-social-links” after=”product.info.overview”><block class=”Magento\Catalog\Block\Product\View” name=”product.info.addto” as=”addto” template=”product/view/addto.phtml”/> <!– adding social sharing block –><block class=”Magento\Catalog\Block\Product\View” name=”product.info.soc” template=”product/view/social.phtml”/> <block class=”Magento\Catalog\Block\Product\View” name=”product.info.mailto” template=”product/view/mailto.phtml”/></container>

We now have to create a new file in the following location:

<child_theme_dir>/Magento_Catalog/templates/product/view/social.phtml

Make sure that you store the images under the following directory:
<child_theme_dir>/web/images/

For more read our social links blog for magento2

1 Answers
mmoliverusselldev answered 5 months ago

There are lots of tutorial on Magento 2 social share . The process is really easy. You have to copy the button codes and paste it in the file, like mentioned in the tutorial.

Your Answer
Login
Enter email and password to comment or answer
Not the answer you are looking for? Browse other questions tagged or ask your own question.