0

I have created attributes like features and specification for product. Can anyone guide me how to show these attributes below details tab on product page. I'm using magento 2.1 with molly theme.Please refer the image. below the details tab.

2 Answers 2

0

In Magento 2 to apply the new tab in product detail page is very easy task. Use below steps and check it out. It will display the tab in your theme.

  1. Create file catalog_product_view.xml in the app/design/frontend/{vender name}/{theme name}/Magento_Catalog/layout

In the file write the below code:

<?xml version="1.0"?>
<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>      
        <referenceBlock name="product.info.details">
        <block class="Magento\Catalog\Block\Product\View" name="deliveryinfo.tab" as="deliveryinfo" template="product/view/delivery_info.phtml" group="detailed_info" >
        <arguments>
        <argument translate="true" name="title" xsi:type="string">Product Question</argument>
        </arguments>
        </block>
        </referenceBlock>
    </body>
</page>
  1. create the file delivery_info.phtml in the path app/design/frontend/{vender name}/{theme name}/Magento_Catalog/templates/product/view.

In the file you can write any content or you can call the static block like this

<?php echo $block->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('delivery_info')->toHtml(); ?>
  1. delivery_info block we have to create in admin side Content/Block.

Now check in the Detail page.

0

The above steps work for blocks, if you want to add product attributes in product view page add following code to delivery_info.phtml :

<?php echo $this->helper('Magento\Catalog\Helper\Output')->productAttribute($block->getProduct(), $block->getProduct()->getattribute_ID(), 'attribute_ID') ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.