0

I am using Magento 2.2.4. I need to add a block for product detail outside from the main 'Details', 'Review' tabs. I need this block to be separated after the main description of the product. I have started doing this with a custom theme but no idea how to do this. I need to add something like a blog post end of the description of the product with images. How can I do this?

0

In your custom module you can add catalog_product_view.xml

app/code/[Vendor]/[Module]/view/frontend/layout/catalog_product_view.xml

<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 class="[Vendor]/[Module]\Block\Product\View\Faq" name="product.info.faq" template="Vendor_Module::product/faq.phtml" after="product.info.details">
                <arguments><argument translate="true" name="title" xsi:type="string">FAQ</argument></arguments>
            </block>
        </referenceContainer>
    </body>
</page>

Than write your custom template.

app/code[Vendor]/[Module]/view/frontend/templates/product/faq.phtml

<?php
echo $block->getProduct();
?>

I hope this answer helps you. If you found it useful please accept it.

  • I have added a custom theme extended from luma. But I have no idea of what really to use whether a module or theme or both. Can you please tell me? – SMash Jul 6 '18 at 7:53
  • You can use any one of them. If you have created a custom module you can use it else in your custom theme you can also place files in layout and template folders. – P_U Jul 6 '18 at 8:24

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.