2

I want to remove tabs(invoice,credit memo,shipment) in sales order view using observer
My config.xml file

    <adminhtml_widget_container_html_before>
                        <observers>
                            <package_test_adminhtml_widget_container_html_before>
                                <class>test/observer</class>
                                <method>adminhtmlWidgetContainerHtmlBefore</method>
                            </package_test_adminhtml_widget_container_html_before>
                        </observers>
    </adminhtml_widget_container_html_before>

My observer.php

public function adminhtmlWidgetContainerHtmlBefore($event) 
    {
        $block = $event->getBlock();
        if ($block instanceof Mage_Adminhtml_Block_Widget_Tabs) {
            $block->removeTab('order_tab_info'); // I am trying information tab from sales order view but it doesn't work          
        }
    }
1

Try this:

In config.xml use core_block_abstract_to_html_before instead adminhtml_widget_container_html_before

<events>
    <core_block_abstract_to_html_before>
        <observers>
            <package_test_adminhtml_widget_container_html_before>
                <class>test/observer</class>
                <method>adminhtmlWidgetContainerHtmlBefore</method>
            </package_test_adminhtml_widget_container_html_before>
        </observers>
    </core_block_abstract_to_html_before>
</events>

and replace your observer adminhtmlWidgetContainerHtmlBefore() with:

public function adminhtmlWidgetContainerHtmlBefore($event) {
    $block = $event->getBlock();
    if ($block instanceof Mage_Adminhtml_Block_Sales_Order_View_Tabs) {
        $block->removeTab('order_transactions');   // Remove tab by id
        $block->removeTab('order_history');        // Remove tab by id
    }
}

Note: Please don't try to remove sales order view current active tab, it will thrown below error:

PHP Fatal error: Call to a member function getId() on a non-object in /var/www/html/magento/app/code/core/Mage/Adminhtml/Block/Widget/Tabs.php on line 236, referer: http://127.0.0.1/magento/index.php/admin/sales_order/index/key/47b8c63b239bfb55d90a12088f642fed/
|improve this answer|||||
0

Make sure You copy your local then check

**Remove Credit memo**

    app\code\core\Mage\Adminhtml\Block\Sales\Order\View\Tab\Creditmemos.php

    public function canShowTab()
        {
            return true; // Set false Here
        }


    **Remove Invoices**

    app\code\core\Mage\Adminhtml\Block\Sales\Order\View\Tab\Invoices.php

    public function canShowTab()
        {
            return true; //Set false
        }

    **Remove Shipments**

         app\code\core\Mage\Adminhtml\Block\Sales\Order\View\Tab\Shipments.php


    public function canShowTab()
        {
            if ($this->getOrder()->getIsVirtual()) {
                return false;
            }
            return true; //set false here
        }
|improve this answer|||||
  • I know this solution but this approach done by three time override block file, but I want with this by observer – Niraj Patel Oct 11 '15 at 4:38
0

Try to replace you code with following

public function adminhtmlWidgetContainerHtmlBefore($event) 
{
    $block = $event->getBlock();
    if ($block instanceof Mage_Adminhtml_Block_Widget_Tabs) {
        $block->removeTab('order_info'); // Check the tab name
    }
}
|improve this answer|||||

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.