Skip to main content

How to add new tab into products backend and frontend ?

Follow below steps to add new tab into backend and frontend, read and apply same changes accordingly.

Create new attribute 'warranty' from Backend : Menu: Catalog >> Attributes >> Manage Attributes

Go on menu: Catalog >> Attributes >> Manage Attribute Sets  and create new Group and drag newly created attribute from right end side (unassigned attributes) into that group.
By above things tab should be added from your BE manage products. Now edit any product and go into Warrenty tab and paste your static block identifier).

Frontend:

1. app/design/frontend/[theme]/default/layout/catalog.xml And find below line:

<block type="catalog/product_view_attributes" name="product.attributes" as="additional" template="catalog/product/view/attributes.phtml">

Now add your own “tab” code afterwards, as below:

<block type="catalog/product_view_attributes" name="product.warranty" as="warranty" template="catalog/product/view/warranty.phtml">
 <action method="addToParentGroup"><group>detailed_info</group></action>
 <action method="setTitle" translate="value"><value>Warranty Guide</value></action>
</block>

now create new file over app/design/frontend/[theme]/default/template/catalog/product/view/warrenty.phtml

And add below code

<?php
$_product = $this->getProduct();
$attribute = $_product->getResource()->getAttribute('warrentry');
if(is_object($attribute)){
  $identifier = $_product->getData("warrentry");
}
?>

<?php if ($_sizeBlock = Mage::app()->getLayout()->createBlock('cms/block')->setBlockId($identifier)): ?>
    <div class="std">
        <?php echo $_sizeBlock->toHtml() ?>
    </div>
<?php endif; ?>

And you done! see how simple it is. .. 

Comments