Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento - Remove tab from product view using local.xml

A really simple question with (I bet) a very simple answer... I want to remove one of the product info tabs from my product view page. I want to remove the tab which shows the attributes, but rather than commenting it out in catalog.xml I want to remove it properly through local.xml.

<action method="addTab" translate="title" module="catalog">
<alias>additional</alias><title>Additional Information</title>
<block>catalog/product_view_attributes</block>
<template>catalog/product/view/attributes.phtml</template>
</action>

I thought there may be a removeTab method, but that didn't work. There's also method="unsetChild", but I cannot see how I would target that specific element as there's no defined name in the XML.

Any ideas would be much appreciated.

like image 388
Adam Moss Avatar asked Oct 18 '11 14:10

Adam Moss


People also ask

How do I remove the Review tab from the product page in Magento 2?

To disable Magento 2 product reviews, go to Stores > Settings > Configuration > Catalog, open the Product Reviews section, and set the Enabled field to No. Don't forget to save changes, clear the cache, and check the result on the frontend. After you do these steps, users won't be allowed to write reviews.

How do I change the layout of a product detail page in Magento 2?

In order to apply custom layout updates for your product pages, you'll need to put an . XML file in a specified folder ( app/design/frontend/<Vendor>/<Theme>/Magento_Catalog/layout/ ). The layout update from that . XML file will then appear under Custom Layout Update as a selectable option.


2 Answers

Based on my reading of Mage_Catalog_Block_Product_View_Tabs::addTabs(), you should be able to remove the block from being rendered with one of the following:

<!-- language: xml -->
<catalog_product_view>
    <reference name="product.info.tabs">
        <action method="unsetChild">
            <child>additional</child>
        </action>
    </reference>
</catalog_product_view>

Or:

<catalog_product_view>
    <remove name="additional" />
</catalog_product_view>

The reason that I believe these will work is that addTab() simply takes the arguments and uses them to create a block instance as a child of the tab parent block.

Zyava's comment is incorrect, as I assume you know. There is a difference between app/etc/local.xml (a config file) and the explicitly last-loaded local.xml from your design settings.

like image 71
benmarks Avatar answered Sep 20 '22 12:09

benmarks


I am using my module adminhtml layout xml to add or remove tabs (you could use your theme's local.xml, based on these steps with a bit of tweakking.)

Firstly you will need to declare your layout updates (in your module config.xml) like the following:

<adminhtml>
    <layout>
        <updates>
            <mymodule>
                <file>mymodule.xml</file>
            </mymodule>
        </updates>
    </layout>
</adminhtml>

Then in mymodule.xml, add the following (here, I am using the admin order view page handle)

<adminhtml_sales_order_view>
    <reference name="sales_order_tabs">
        <action method="removeTab">
            <name>order_shipments</name>
        </action>
        <action method="addTabAfter">
            <name>order_shipments_mymodule</name>
            <block>mymodule/adminhtml_order_shipments</block>
            <after>order_creditmemos</after>
        </action>
        <action method="addTab">
            <name>order_receipts</name>
            <block>mymoduled/adminhtml_order_recp</block>
        </action>
    </reference>
</adminhtml_sales_order_view>

Hope this helps!! (Don't forget to upvote this solution)

like image 35
Fadzly Othman Avatar answered Sep 22 '22 12:09

Fadzly Othman