1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
26:
27: 28: 29: 30: 31: 32: 33:
34:
35: class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Tag_Customer extends Mage_Adminhtml_Block_Widget_Grid
36: {
37: public function __construct()
38: {
39: parent::__construct();
40: $this->setId('tag_customers_grid');
41: $this->setDefaultSort('firstname');
42: $this->setDefaultDir('ASC');
43: $this->setUseAjax(true);
44: }
45:
46: protected function _prepareCollection()
47: {
48: if (Mage::helper('catalog')->isModuleEnabled('Mage_Tag')) {
49: $collection = Mage::getModel('tag/tag')
50: ->getCustomerCollection()
51: ->addProductFilter($this->getProductId())
52: ->addGroupByTag()
53: ->addDescOrder();
54:
55: $this->setCollection($collection);
56: }
57: return parent::_prepareCollection();
58: }
59:
60: protected function _afterLoadCollection()
61: {
62: return parent::_afterLoadCollection();
63: }
64:
65: protected function _prepareColumns()
66: {
67: $this->addColumn('firstname', array(
68: 'header' => Mage::helper('catalog')->__('First Name'),
69: 'index' => 'firstname',
70: ));
71:
72: $this->addColumn('lastname', array(
73: 'header' => Mage::helper('catalog')->__('Last Name'),
74: 'index' => 'lastname',
75: ));
76:
77: $this->addColumn('email', array(
78: 'header' => Mage::helper('catalog')->__('Email'),
79: 'index' => 'email',
80: ));
81:
82: $this->addColumn('name', array(
83: 'header' => Mage::helper('catalog')->__('Tag Name'),
84: 'index' => 'name',
85: ));
86:
87: return parent::_prepareColumns();
88: }
89:
90: public function getRowUrl($row)
91: {
92: return $this->getUrl('*/customer/edit', array('id' => $row->getCustomerId()));
93: }
94:
95: public function getGridUrl()
96: {
97: return $this->getUrl('*/catalog_product/tagCustomerGrid', array(
98: '_current' => true,
99: 'id' => $this->getProductId(),
100: 'product_id' => $this->getProductId(),
101: ));
102: }
103: }
104: