Mage_Adminhtml_Block_Customer_Grid Class Reference

Inheritance diagram for Mage_Adminhtml_Block_Customer_Grid:

Mage_Adminhtml_Block_Widget_Grid Mage_Adminhtml_Block_Widget Mage_Adminhtml_Block_Template Mage_Core_Block_Template Mage_Core_Block_Abstract Varien_Object

List of all members.

Public Member Functions

 __construct ()
 getGridUrl ()
 getRowUrl ($row)

Protected Member Functions

 _prepareCollection ()
 _prepareColumns ()
 _prepareMassaction ()


Detailed Description

Definition at line 34 of file Grid.php.


Constructor & Destructor Documentation

__construct (  ) 

Constructor

By default is looking for first argument as array and assignes it as object attributes This behaviour may change in child classes

Reimplemented from Varien_Object.

Definition at line 37 of file Grid.php.

00038     {
00039         parent::__construct();
00040         $this->setId('customerGrid');
00041         $this->setUseAjax(true);
00042         $this->setDefaultSort('entity_id');
00043     }


Member Function Documentation

_prepareCollection (  )  [protected]

Prepare grid collection object

Returns:
this

Reimplemented from Mage_Adminhtml_Block_Widget_Grid.

Definition at line 45 of file Grid.php.

00046     {
00047         $collection = Mage::getResourceModel('customer/customer_collection')
00048             ->addNameToSelect()
00049             ->addAttributeToSelect('email')
00050             ->addAttributeToSelect('created_at')
00051             ->addAttributeToSelect('group_id')
00052             ->joinAttribute('billing_postcode', 'customer_address/postcode', 'default_billing', null, 'left')
00053             ->joinAttribute('billing_city', 'customer_address/city', 'default_billing', null, 'left')
00054             ->joinAttribute('billing_telephone', 'customer_address/telephone', 'default_billing', null, 'left')
00055             ->joinAttribute('billing_region', 'customer_address/region', 'default_billing', null, 'left')
00056             ->joinAttribute('billing_country_id', 'customer_address/country_id', 'default_billing', null, 'left');
00057 
00058         $this->setCollection($collection);
00059 
00060         return parent::_prepareCollection();
00061     }

_prepareColumns (  )  [protected]

Reimplemented from Mage_Adminhtml_Block_Widget_Grid.

Definition at line 63 of file Grid.php.

00064     {
00065         $this->addColumn('entity_id', array(
00066             'header'    => Mage::helper('customer')->__('ID'),
00067             'width'     => '50px',
00068             'index'     => 'entity_id',
00069             'type'  => 'number',
00070         ));
00071         /*$this->addColumn('firstname', array(
00072             'header'    => Mage::helper('customer')->__('First Name'),
00073             'index'     => 'firstname'
00074         ));
00075         $this->addColumn('lastname', array(
00076             'header'    => Mage::helper('customer')->__('Last Name'),
00077             'index'     => 'lastname'
00078         ));*/
00079         $this->addColumn('name', array(
00080             'header'    => Mage::helper('customer')->__('Name'),
00081             'index'     => 'name'
00082         ));
00083         $this->addColumn('email', array(
00084             'header'    => Mage::helper('customer')->__('Email'),
00085             'width'     => '150',
00086             'index'     => 'email'
00087         ));
00088 
00089         $groups = Mage::getResourceModel('customer/group_collection')
00090             ->addFieldToFilter('customer_group_id', array('gt'=> 0))
00091             ->load()
00092             ->toOptionHash();
00093 
00094         $this->addColumn('group', array(
00095             'header'    =>  Mage::helper('customer')->__('Group'),
00096             'width'     =>  '100',
00097             'index'     =>  'group_id',
00098             'type'      =>  'options',
00099             'options'   =>  $groups,
00100         ));
00101 
00102         $this->addColumn('Telephone', array(
00103             'header'    => Mage::helper('customer')->__('Telephone'),
00104             'width'     => '100',
00105             'index'     => 'billing_telephone'
00106         ));
00107 
00108         $this->addColumn('billing_postcode', array(
00109             'header'    => Mage::helper('customer')->__('ZIP'),
00110             'width'     => '90',
00111             'index'     => 'billing_postcode',
00112         ));
00113 
00114         $this->addColumn('billing_country_id', array(
00115             'header'    => Mage::helper('customer')->__('Country'),
00116             'width'     => '100',
00117             'type'      => 'country',
00118             'index'     => 'billing_country_id',
00119         ));
00120 
00121         $this->addColumn('billing_region', array(
00122             'header'    => Mage::helper('customer')->__('State/Province'),
00123             'width'     => '100',
00124             'index'     => 'billing_region',
00125         ));
00126 
00127         $this->addColumn('customer_since', array(
00128             'header'    => Mage::helper('customer')->__('Customer Since'),
00129             'type'      => 'datetime',
00130             'align'     => 'center',
00131             'index'     => 'created_at',
00132             'gmtoffset' => true
00133         ));
00134 
00135         if (!Mage::app()->isSingleStoreMode()) {
00136             $this->addColumn('website_id', array(
00137                 'header'    => Mage::helper('customer')->__('Website'),
00138                 'align'     => 'center',
00139                 'width'     => '80px',
00140                 'type'      => 'options',
00141                 'options'   => Mage::getSingleton('adminhtml/system_store')->getWebsiteOptionHash(true),
00142                 'index'     => 'website_id',
00143             ));
00144         }
00145 
00146         $this->addColumn('action',
00147             array(
00148                 'header'    =>  Mage::helper('customer')->__('Action'),
00149                 'width'     => '100',
00150                 'type'      => 'action',
00151                 'getter'    => 'getId',
00152                 'actions'   => array(
00153                     array(
00154                         'caption'   => Mage::helper('customer')->__('Edit'),
00155                         'url'       => array('base'=> '*/*/edit'),
00156                         'field'     => 'id'
00157                     )
00158                 ),
00159                 'filter'    => false,
00160                 'sortable'  => false,
00161                 'index'     => 'stores',
00162                 'is_system' => true,
00163         ));
00164 
00165         $this->addExportType('*/*/exportCsv', Mage::helper('customer')->__('CSV'));
00166         $this->addExportType('*/*/exportXml', Mage::helper('customer')->__('XML'));
00167         return parent::_prepareColumns();
00168     }

_prepareMassaction (  )  [protected]

Prepare grid massaction actions

Returns:
Mage_Adminhtml_Block_Widget_Grid

Reimplemented from Mage_Adminhtml_Block_Widget_Grid.

Definition at line 170 of file Grid.php.

00171     {
00172         $this->setMassactionIdField('entity_id');
00173         $this->getMassactionBlock()->setFormFieldName('customer');
00174 
00175         $this->getMassactionBlock()->addItem('delete', array(
00176              'label'    => Mage::helper('customer')->__('Delete'),
00177              'url'      => $this->getUrl('*/*/massDelete'),
00178              'confirm'  => Mage::helper('customer')->__('Are you sure?')
00179         ));
00180 
00181         $this->getMassactionBlock()->addItem('newsletter_subscribe', array(
00182              'label'    => Mage::helper('customer')->__('Subscribe to newsletter'),
00183              'url'      => $this->getUrl('*/*/massSubscribe')
00184         ));
00185 
00186         $this->getMassactionBlock()->addItem('newsletter_unsubscribe', array(
00187              'label'    => Mage::helper('customer')->__('Unsubscribe from newsletter'),
00188              'url'      => $this->getUrl('*/*/massUnsubscribe')
00189         ));
00190 
00191         $groups = $this->helper('customer')->getGroups()->toOptionArray();
00192 
00193         array_unshift($groups, array('label'=> '', 'value'=> ''));
00194         $this->getMassactionBlock()->addItem('assign_group', array(
00195              'label'        => Mage::helper('customer')->__('Assign a customer group'),
00196              'url'          => $this->getUrl('*/*/massAssignGroup'),
00197              'additional'   => array(
00198                 'visibility'    => array(
00199                      'name'     => 'group',
00200                      'type'     => 'select',
00201                      'class'    => 'required-entry',
00202                      'label'    => Mage::helper('customer')->__('Group'),
00203                      'values'   => $groups
00204                  )
00205             )
00206         ));
00207 
00208         return $this;
00209     }

getGridUrl (  ) 

Reimplemented from Mage_Adminhtml_Block_Widget_Grid.

Definition at line 211 of file Grid.php.

00212     {
00213         return $this->getUrl('*/*/grid', array('_current'=> true));
00214     }

getRowUrl ( row  ) 

Definition at line 216 of file Grid.php.

00217     {
00218         return $this->getUrl('*/*/edit', array('id'=>$row->getId()));
00219     }


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:22:48 2009 for Magento by  doxygen 1.5.8