1

i added below code for custom tab

My New Custom Tab>My New Custom Tabcore/templatecatalog/product/mynewcustomtab.phtml

but it show for all products now if i want to enable it only for configurable product what should i do for it

2 Answers 2

1

Magento have call new layout handler(PRODUCT_TYPE_configurable) for configurable product.

In Mage_Catalog_Helper_Product_View class at function initProductLayout magento is add ed new layout PRODUCT_TYPE_producttypeid" see at

$update->addHandle('PRODUCT_TYPE_' . $product->getTypeId());
$update->addHandle('PRODUCT_' . $product->getId()); 

Depends on this,magento is calling different block on each type

In catalog.xml file you have seen magento is add Additional block dependant on product type

  <PRODUCT_TYPE_configurable translate="label" module="catalog">
        <label>Catalog Product View (Configurable)</label>
        <reference name="product.info">
            <block type="catalog/product_view_type_configurable" name="product.info.configurable" as="product_type_data" template="catalog/product/view/type/default.phtml">
                <block type="core/text_list" name="product.info.configurable.extra" as="product_type_data_extra" translate="label">
                    <label>Product Extra Info</label>
                </block>
            </block>
            <block type="catalog/product_view_type_configurable" name="product.info.availability" as="product_type_availability" template="catalog/product/view/type/availability/default.phtml" />
        </reference>
        <reference name="product.info.options.wrapper">
            <block type="catalog/product_view_type_configurable" name="product.info.options.configurable" as="options_configurable" before="-" template="catalog/product/view/type/options/configurable.phtml">
                <block type="core/text_list" name="product.info.options.configurable.renderers" as="attr_renderers" />
                <block type="core/text_list" name="product.info.options.configurable.after" as="after" />
            </block>
        </reference>
    </PRODUCT_TYPE_configurable>

You have seen that above code there magento is add some block depends on product type just configgurable product dropdown.

So you can do the same ways

<PRODUCT_TYPE_configurable>
    <reference name="yourBlockReferencName">
        <block type="core/template" template="catalog/product/mynewcustomtab.phtml"/>
    </reference>
</PRODUCT_TYPE_configurable>

You need added this code on layout file or catalog.xml

1
  • can u guide hwo to add in Magento2? for the configurable product in the frontend Dec 28, 2019 at 14:01
0

Check the below condition of before your tabs if product type is configurable then inside of for loop

if($_product->getTypeId() == "configurable"):

or

$product->isConfigurable();

Hope this helps

Thanks

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.