Monday, 16 March 2015

Rename or remove [Add New] button from grid in magento admin

Normally, the [Add New] button is present on upper right corner of Grid Page in Magento backend. If you don’t wish to show the [Add New] button in the Grid you need to code a little to disable it.
How to rename [Add New] button
Go to grid page block file, the directory likes app -> code -> local -> YourNamespace -> YourModule -> Block -> Adminhtml -> YourFile.php
Then add the following code to __construct function
?
1
$this->_addButtonLabel = Mage::helper('yourmodulename')->__('Add Report'); //you can replace 'Add Report' with any text you want
How to remove [Add New] button
Go to grid page block file, the directory likes app -> code -> local -> YourNamespace -> YourModule -> Block -> Adminhtml -> YourFile.php
Then add the following code to __construct function(note: the remove statement code must be under the parent constructor statement)
?
1
2
parent::__construct();
$this->_removeButton('add');
Also, how to remove back, delete, and save button in edit page
Go to grid page block file, the directory likes app -> code -> local -> YourNamespace -> YourModule -> Block -> Adminhtml -> YourFile -> edit.php
Then add the following code to __construct function(note: the remove statement code must be under the parent constructor statement)
?
1
2
3
4
parent::__construct();
$this->_removeButton('delete');
$this->_removeButton('save');
$this->_removeButton('back');



No comments:

Post a Comment