00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 class Mage_Adminhtml_Block_Customer_Edit_Tab_Tag extends Mage_Adminhtml_Block_Widget_Grid
00035 {
00036
00037 public function __construct()
00038 {
00039 parent::__construct();
00040 $this->setId('tag_grid');
00041 $this->setDefaultSort('name');
00042 $this->setDefaultDir('ASC');
00043 $this->setUseAjax(true);
00044 $this->setFilterVisibility(false);
00045 }
00046
00047 protected function _prepareCollection()
00048 {
00049 $tagId = Mage::registry('tagId');
00050
00051 if( $this->getCustomerId() instanceof Mage_Customer_Model_Customer ) {
00052 $this->setCustomerId( $this->getCustomerId()->getId() );
00053 }
00054
00055 $collection = Mage::getResourceModel('tag/customer_collection')
00056 ->addCustomerFilter($this->getCustomerId());
00057
00058 $this->setCollection($collection);
00059 return parent::_prepareCollection();
00060 }
00061
00062 protected function _afterLoadCollection()
00063 {
00064 $this->getCollection()->addProductName();
00065 return parent::_afterLoadCollection();
00066 }
00067
00068 protected function _prepareColumns()
00069 {
00070 $this->addColumn('name', array(
00071 'header' => Mage::helper('customer')->__('Tag Name'),
00072 'index' => 'name',
00073 ));
00074
00075 $this->addColumn('status', array(
00076 'header' => Mage::helper('customer')->__('Status'),
00077 'width' => '90px',
00078 'index' => 'status',
00079 'type' => 'options',
00080 'options' => array(
00081 Mage_Tag_Model_Tag::STATUS_DISABLED => Mage::helper('customer')->__('Disabled'),
00082 Mage_Tag_Model_Tag::STATUS_PENDING => Mage::helper('customer')->__('Pending'),
00083 Mage_Tag_Model_Tag::STATUS_APPROVED => Mage::helper('customer')->__('Approved'),
00084 ),
00085 'filter' => false,
00086 ));
00087
00088 $this->addColumn('product', array(
00089 'header' => Mage::helper('customer')->__('Product Name'),
00090 'index' => 'product',
00091 'filter' => false,
00092 'sortable' => false,
00093 ));
00094
00095 $this->addColumn('product_sku', array(
00096 'header' => Mage::helper('customer')->__('SKU'),
00097 'index' => 'product_sku',
00098 'filter' => false,
00099 'sortable' => false,
00100 ));
00101
00102 return parent::_prepareColumns();
00103 }
00104
00105 protected function getRowUrl($row)
00106 {
00107 return $this->getUrl('*/tag/edit', array(
00108 'tag_id' => $row->getTagId(),
00109 'customer_id' => $this->getCustomerId(),
00110 ));
00111 }
00112
00113 public function getGridUrl()
00114 {
00115 return $this->getUrl('*/customer/tagGrid', array(
00116 '_current' => true,
00117 'id' => $this->getCustomerId()
00118 ));
00119 }
00120
00121 }