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_Tag_Product_Grid extends Mage_Adminhtml_Block_Widget_Grid
00035 {
00036
00037 public function __construct()
00038 {
00039 parent::__construct();
00040 $this->setId('tag_grid' . Mage::registry('tagId'));
00041 $this->setDefaultSort('name');
00042 $this->setDefaultDir('ASC');
00043 }
00044
00045 protected function _prepareCollection()
00046 {
00047 $tagId = Mage::registry('tagId');
00048 $collection = Mage::getModel('tag/tag')
00049 ->getEntityCollection()
00050 ->addTagFilter($tagId)
00051 ->addPopularity($tagId);
00052
00053 $this->setCollection($collection);
00054 return parent::_prepareCollection();
00055 }
00056
00057 protected function _afterLoadCollection()
00058 {
00059 return parent::_afterLoadCollection();
00060 }
00061
00062 protected function _prepareColumns()
00063 {
00064 $this->addColumn('product_id', array(
00065 'header' => Mage::helper('tag')->__('ID'),
00066 'width' => '50px',
00067 'align' => 'right',
00068 'index' => 'entity_id',
00069 ));
00070
00071 $this->addColumn('name', array(
00072 'header' => Mage::helper('tag')->__('Product Name'),
00073 'index' => 'name',
00074 ));
00075
00076 $this->addColumn('popularity', array(
00077 'header' => Mage::helper('tag')->__('# of Uses'),
00078 'width' => '50px',
00079 'align' => 'right',
00080 'index' => 'popularity',
00081 'type' => 'number'
00082 ));
00083
00084 return parent::_prepareColumns();
00085 }
00086
00087 protected function _addColumnFilterToCollection($column)
00088 {
00089 if($column->getIndex() == 'popularity') {
00090 $this->getCollection()->addPopularityFilter($column->getFilter()->getCondition());
00091 return $this;
00092 } else {
00093 return parent::_addColumnFilterToCollection($column);
00094 }
00095 }
00096
00097 protected function getRowUrl($row)
00098 {
00099 return $this->getUrl('*/catalog_product/edit', array('id' => $row->getProductId()));
00100 }
00101
00102 }