4

I'm struggling with a Magento 2 issue here. With Venustheme Cropshop installed I'm trying to add an extra tab with listed info to de product detail page. Please check the below image:

enter image description here I already saw Trần Đăng Phong's question, but that one is solved with code. It seems more logical to fix it within the admin. That SHOULD be possible right?

I managed to add a list of attributes (Fats, Carbs, etc.) in an attribute set (Nutritionfacts), but it pops-up under the "more info"-tab. I'd like this info to show in a new tab "Nutrition facts".

Hope someone can help.

  • I don't think there are any methods to add product tab without coding. But I think it's good to be a feature in future. – PY Yick Jun 30 '17 at 10:03
3

To add an extra tab you need to do some coding

for example I am adding delivery tab

To edit and update catalog_product_view.xml go to below location

app\design\frontend\vendorname\themename\Magento_Catalog\layout\catalog_product_view.xml

if file is not here the override with

vendor/magento/module-catalog/view/frontend/layout/catalog_product_view.xml

Now Add below code for adding delivery tab

<block class="Magento\Catalog\Block\Product\View\Description" name="product.delivery" as="features" template="product/view/delivery.phtml" group="detailed_info">
                <arguments>
                    <argument translate="true" name="title" xsi:type="string">Delivery</argument>
                    <argument name="priority" xsi:type="string">3</argument>
                </arguments>
            </block>

Place delivery.phtml file under

app/design/frontend/vendorname/themename/Magento_Catalog/templates/product/view/delivery.phtml

To add content via admin block create a block delivery-tab and use below code in delivery.phtml file

<?php echo $block->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('delivery-tab')->toHtml();?>

I hope this will solve your problem. If don't see any change then please run , upgrade, deploy and cache commands after this

  • Somehow this doesn't work for me. Creating a block wouldn't solve my problem. Instead, I'd like to show an attribute of the corresponding product. – Rick Jun 30 '17 at 12:21
  • okay, please update your question to get the right help – Manoj Deswal Jun 30 '17 at 12:23

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.