Remove column customer grid with observer

by Ziru Zanrgeiff   Last Updated August 27, 2018 10:09 AM

I'm trying to remove some columns from customer grid, but is not working, I've tried several similar events, but none of them work.

my config.xml

<adminhtml>
    <events>
        <core_block_abstract_to_html_before>
            <observers>
                <manage_adminhtml>
                    <class>manage_adminhtml/observer</class>
                    <method>getCustomerGrid</method>
                </manage_adminhtml>
            </observers>
        </core_block_abstract_to_html_before>
    </events>
</adminhtml>

and my observer

class Manage_Adminhtml_Model_Observer
{
    public function getCustomerGrid( $observer )
    {
        $block = $observer->getEvent()->getBlock();

        if ($block->getId() == 'customerGrid') {

            $block->removeColumn('group');
            $block->removeColumn('email');

            $block->sortColumnsByOrder();
        }
    }
}


Answers 1


What you want to do can be achieved with GridControl.

We use the event adminhtml_block_html_before and then call $params->getBlock()->removeColumn($params->getColumn()->getName());

Fabian Blechschmidt
Fabian Blechschmidt
June 18, 2016 06:41 AM

Related Questions



What's wrong with my event observer?

Updated September 27, 2017 00:09 AM

Customer save after event magento2

Updated November 23, 2018 15:09 PM

forgot password event for frontend

Updated July 02, 2017 17:09 PM