I want to create a custom product detail tab "Q&A" and only display the tab when there is an Q&A questions exist for the product, and the tab will be the hyperlink to the FAQ page ( for example: www.abc.com/kbase/search/query/[SKU])

For magento 2, I only know we can create the custom product tab using catalog_product_view.xml, i'm not sure how to implement this.

below is how it's currently done in magento 1, using view.phtml

    <div class="details">
        <ul class="tabs">
            <?php { ?>
            <li id="show-all" class="current"><a href="javascript:;">Overview</a></li>
            <?php } ?>
            <?php if( $_product->getFeatures() || $_product->getSpecifications() ){ ?>
            <li id="specifications"><a href="javascript:;">Specifications</a></li>
            <?php } ?>

                $query = $_helper->productAttribute($_product, $_product->getsku(), 'sku');
                $object = Mage::getModel("kbase/article")->getCollection()->addSearchFilter($query);
                if(count($object)>0) {
            <li id="q_and_a"><a href='/kbase/search/query/<?php echo $_helper->productAttribute($_product, $_product->getsku(), 'sku'); ?>/' target='_blank'>Q&A</a></li>
            <?php } ?>

        <div class="text" id="div_q_and_a">
        <?php if( $_product->getQAndA() ){ ?>
            <div style="float:left; clear:both; padding-bottom:20px; width:100%;">
                <?php echo $this->getChildHtml('q_and_a') ?>
        <?php } ?>

  • do you have any attribute in admin for Q&A ?Or you are using any module ? – Pawan Mar 6 '19 at 2:27
  • there is no attribute in admin for Q&A. i'm using Aheadworks knowledgebase extension – Kris Wen Mar 6 '19 at 23:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.