3

How to add custom .phtml file in product details page. I also try this code in catalog_product_view.xml file, but can't working. enter image description here

5

Please use below code:

<?xml version="1.0"?>
<!--
/**
 * Copyright © 2015 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="content">
            <block after="product.info.details" class="Vendor/Module/Block/Module" name="extra" template="Vendor_Module::extra.phtml" />        
        </referenceContainer>
    </body>
</page>
  • Can I add this custom.phtml file in product page on installation of a plugin? – Akash Agrawal Jan 8 '18 at 6:43
1

You can try below code, Your phtml file content will display near social icon, You can change referenceBlock name if you want to change position

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>        
        <referenceBlock name="product.info.social">
            <block class="Example\Examples\Block\Question" name="example.tab" template="Example_Examples::success.phtml">
            </block>
        </referenceBlock>
    </body>
</page>

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.