Magento – How to add Upload Button for importing a csv file in the Custom Admin Grid Container

csvmagento-1.8magento-1.9upload

I'm creating a custom module where i have a requirement to add a upload button to the Grid container for uplaoding a csv file and execute it to update a attribute value in the database. how do i achieve this.enter image description here

Best Answer

Add button as per following:

class XYZ_Brand_Block_Adminhtml_Brand extends Mage_Adminhtml_Block_Widget_Grid_Container {

    public function __construct() {
        $this->_controller = 'adminhtml_brand';
        $this->_blockGroup = 'brand';
        $this->_headerText = Mage::helper('core')->__('Sample Text');
        parent::__construct();
        $this->_removeButton('add');

        $this->_addButton("Import", array(
            "label" => Mage::helper("core")->__("Import"),
            "onclick" => "location.href = '" . $this->getUrl('brand/adminhtml_import') . "';",
            "class" => "btn btn-danger",
        ));

    }

}