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: class Mage_Adminhtml_Block_Tag_Grid_Products extends Mage_Adminhtml_Block_Widget_Grid
35: {
36:
37: protected function _prepareCollection()
38: {
39: $collection = Mage::getResourceModel('tag/product_collection')
40: ->addAttributeToSelect('sku')
41: ->addAttributeToSelect('name')
42: ;
43: if ($tagId = $this->getRequest()->getParam('tag_id')) {
44: $collection->addTagFilter($tagId);
45: }
46: if ($customerId = $this->getRequest()->getParam('customer_id')) {
47: $collection->addCustomerFilter($customerId);
48: }
49: $this->setCollection($collection);
50:
51: return parent::_prepareCollection();
52: }
53:
54: protected function _prepareColumns()
55: {
56: $this->addColumn('product_id', array(
57: 'header' => Mage::helper('tag')->__('ID'),
58: 'align' => 'center',
59: 'width' => '60px',
60: 'sortable' => false,
61: 'index' => 'product_id'
62: ));
63: $this->addColumn('sku', array(
64: 'header' => Mage::helper('tag')->__('SKU'),
65: 'align' => 'center',
66: 'index' => 'sku'
67: ));
68: $this->addColumn('name', array(
69: 'header' => Mage::helper('tag')->__('Name'),
70: 'index' => 'name'
71: ));
72: $this->addColumn('tags', array(
73: 'header' => Mage::helper('tag')->__('Tags'),
74: 'index' => 'tags',
75: 'sortable' => false,
76: 'filter' => false,
77: 'renderer' => 'adminhtml/tag_grid_column_renderer_tags'
78: ));
79: $this->addColumn('action', array(
80: 'header' => Mage::helper('tag')->__('Action'),
81: 'align' => 'center',
82: 'width' => '120px',
83: 'format' => '<a href="'.$this->getUrl('*/*/customers/product_id/$product_id').'">'.Mage::helper('tag')->__('View Customers').'</a>',
84: 'filter' => false,
85: 'sortable' => false,
86: 'is_system' => true
87: ));
88:
89: return parent::_prepareColumns();
90: }
91:
92: }
93:
94: