I want to remove "Add new" Button from Admin Grid conditionally. Condition is if it has flag for adding then button will display otherwise not

Kindly help.


1 Answer 1


I will try to shed light on how the Add New button in the Catalog -> Product grid is displayed and what can be maybe done about it.

If you open file


you will notice that this class extends


This Container class provides the method


which as its first parameter accepts string: the button ID.

So, take a look at the method prepareLayout and you will notice

$this->_addButton('add_new', array(
        'label'   => Mage::helper('catalog')->__('Add Product'),
        'onclick' => "setLocation('{$this->getUrl('*/*/new')}')",
        'class'   => 'add'

After this the button id is: add_new

The Container class also provides a method


which accepts only one attribute: the button ID

This given, you should probably override the block that defines the button.

In more details, override the _prepareLayout method and use the _addButton conditionally in the first place (so you don't have to remove at all).

Or in other cases, where applicable, just call


In my example it would be


Of course, you can enclose this code in IF statement with whatever condition you need.

  • You are very welcome! :)
    – Marjan
    Sep 6, 2018 at 8:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.