Posts Tagged ‘grid’

Hello All,

Today i found how to set default filter in product grid by product type (e.g.  ‘simple’) in admin product grid. For that you need to rewrite grid.php class of product in path  yourproject/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Grid.php

You need to add below code in _construct() method of grid.php


  $this->setDefaultFilter( array(
                'type' => constant(get_class(Mage::getSingleton('catalog/product_type')) . '::TYPE_SIMPLE'),
            )); 

In above code ‘type’ is field and “constant(get_class(Mage::getSingleton(‘catalog/product_type’)) . ‘::TYPE_SIMPLE’)” is value, you can change its value as per your requirement.

I hope this code will help you, Thanks for reading my blog.

Thanks,

Bijal Bhavsar 🙂

Hello guys,

We can add new action in grid row like ‘Edit’ link at admin grid.

Open your module Grid.php file, below is path to file:
(i.e. yourproject/app/code/local/yourcompany/yourmodulename/block/adminhtml/modulename/grid.php)

In That file, search ‘action’ column, it will be like below code:


$this->addColumn('action',
array(
          'header' => Mage::helper('modulename')->__('Action'),
          'width' => '100',
          'type' => 'action',
          'getter' => 'getId',
          'actions' => array(
                 array(
                      'caption' => Mage::helper('modulename')->__('View'),
                      'url' => array('base'=> '*/*/view'),
                      'field' => 'id'
                    )),
          'filter' => false,
          'sortable' => false,
          'index' => 'stores',
          'is_system' => true,
));

To add new action, you need to add another array in parameter ‘actions’ like below


array(
    'caption' => Mage::helper('modulename')->__('Edit'),
    'url' => array('base'=> '*/*/edit'),
    'field' => 'id'
)

So now code will be like below:



$this->addColumn('action', array(
                      'header' => Mage::helper('modulename')->__('Action'),
                      'width' => '100',
                      'type' => 'action',
                      'getter' => 'getId',
                      'actions' => array(
                              array(
                                 'caption' => Mage::helper('modulename')->__('View'),
                                 'url' => array('base'=> '*/*/view'),
                                 'field' => 'id'
                              ),
                              array(
                                  'caption' => Mage::helper('modulename')->__('Edit'),
                                  'url' => array('base'=> '*/*/edit'),
                                  'field' => 'id'
                              )
                      ),
                      'filter' => false,
                      'sortable' => false,
                      'index' => 'stores',
                      'is_system' => true,
                )
);

I hope the above information will help you.

Thanks,
Bijal Bhavsar 🙂