Thursday, June 25, 2015

how to add custom additional tab for my magento description

Hi guys if you are looking for how to make your own custom tag in magento product description section like specification, benefits or ingredients you need to play with attributes. In my case I have made two tabs benefits or ingredients. The process of adding extra tabs I am describing here hope this will help you.
1.       You need to modify a file which is app/design/frontend/YOUR_THEME/default/layout/catalog.xml
Look for the code

<block type="catalog/product_view_description" name="product.description" as="description" template="catalog/product/view/description.phtml">
                    <action method="addToParentGroup"><group>detailed_info</group></action>
                    <action method="setTitle" translate="value"><value>HOW TO USE</value></action>
                </block>

Under this code you need to add a block in my case I have added two blocks

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


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

After that you need to create phtml file for each block which will be saved under app/design/frontend/YOUR_TEMPLATE/default/template/catalog/product/view
I have made two files benefits.phtml and ingredients.phtml as described you I had added two blocks under these phtml file you need to write some codes. In benefits I have written

<?php $_helper = $this->helper('catalog/output'); ?>
<?php $_product = $this->getProduct(); ?>
<?php if ($_product->getbenefits()):?>
                <div class="short-benefits">
                    <h2><?php echo $this->__('benefits') ?></h2>
                    <div class="std"><?php echo $_helper->productAttribute($_product, nl2br($_product->getbenefits()), 'benefits') ?></div>
                </div>
            <?php endif;?>

And in ingredients I have written

<?php $_helper = $this->helper('catalog/output'); ?>
<?php $_product = $this->getProduct(); ?>
<?php if ($_product->getingredients()):?>
                <div class="short-ingredients">
                    <h2><?php echo $this->__('ingredients') ?></h2>
                    <div class="std"><?php echo $_helper->productAttribute($_product, nl2br($_product->getingredients()), 'ingredients') ?></div>
                </div>
            <?php endif;?>

Once these you have completed you need to login to you magento admin panel and go to
Catalog->attributes->manage attribute



Click on add new and assign the same name as defined in the block like in name=” product.benefits” then make the attribute with benefits name in Catalog Input Type for Store Owner select text area.
If you wish to allow html editor then in Enable WYSIWYG select yes



Now in the left hand side manage label / options
Put the name of the tab like benefits



Now you have made your attribute to assign it you need go to catalog->attributes-> manage attribute sets



Over these select default. Once you click on default you will see in right Unassigned Attributes with the attribute that you have made simpally you need to drag it to your group I had put it after short_description and click on save. Now you are done.

Go catalog manage product and you will see a box that will ask you to enter benefits once you put the content over there it will show up in your produt desctiption page or product view page of your mangento store.



final result

Related Posts:

  • [Solved] How To Import Export Product in Magento? Well i had scenario that i have upload all the product and categories on my local host Magento store now what i had to is to make the website live and i had configured it live but the challenge came to me is i have to upload… Read More
  • Important Command Ado.Net With the release of the .NET Framework, Microsoft introduced a new data access model, called ADO.NET.The five major objects in ADO.NET are: Obects Description Connection The Connection object is responsible for establishing… Read More
  • can not login to magento after installation Hi guys if you can not login to magento admin panel after installation it's not an issue. All what you need to do is you will have to modify up a file of magento. Go to: app\code\core\Mage\Core\Model\Session\Abstr… Read More
  • Difference Between DataReader, DataSet, DataAdapter and DataTable in C# DataReader DataReader is used to read the data from database and it is a read and forward only connection oriented architecture during fetch the data from database. DataReader will fetch the data very fast when compared wit… Read More
  • Paypal Error (35) error 14094410: SSLV3 zencart If you are using zencart 1.5.1 and payment getway as paypal then you might get a error message Paypal Error (35) error 14094410: SSLV3. This is acctually because of update from paypal you can see the SSLV3 paypal update her… Read More

0 comments:

Post a Comment