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
00035 class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Tag extends Mage_Adminhtml_Block_Widget_Grid
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 }
00045
00046 protected function _prepareCollection()
00047 {
00048 $tagId = Mage::registry('tagId');
00049 $collection = Mage::getModel('tag/tag')
00050 ->getResourceCollection()
00051 ->addProductFilter($this->getProductId())
00052 ->addPopularity($tagId);
00053
00054 $this->setCollection($collection);
00055 return parent::_prepareCollection();
00056 }
00057
00058 protected function _afterLoadCollection()
00059 {
00060 return parent::_afterLoadCollection();
00061 }
00062
00063 protected function _prepareColumns()
00064 {
00065 $this->addColumn('name', array(
00066 'header' => Mage::helper('catalog')->__('Tag Name'),
00067 'index' => 'name',
00068 ));
00069
00070 $this->addColumn('popularity', array(
00071 'header' => Mage::helper('catalog')->__('# of Use'),
00072 'width' => '50px',
00073 'align' => 'right',
00074 'index' => 'popularity',
00075 'type' => 'number',
00076 ));
00077
00078 $this->addColumn('status', array(
00079 'header' => Mage::helper('catalog')->__('Status'),
00080 'width' => '90px',
00081 'index' => 'status',
00082 'type' => 'options',
00083 'options' => array(
00084 Mage_Tag_Model_Tag::STATUS_DISABLED => Mage::helper('catalog')->__('Disabled'),
00085 Mage_Tag_Model_Tag::STATUS_PENDING => Mage::helper('catalog')->__('Pending'),
00086 Mage_Tag_Model_Tag::STATUS_APPROVED => Mage::helper('catalog')->__('Approved'),
00087 ),
00088 ));
00089
00090 return parent::_prepareColumns();
00091 }
00092
00093 protected function getRowUrl($row)
00094 {
00095 return $this->getUrl('*/tag/edit', array(
00096 'tag_id' => $row->getId(),
00097 'product_id' => $this->getProductId(),
00098 ));
00099 }
00100
00101 public function getGridUrl()
00102 {
00103 return $this->getUrl('*/catalog_product/tagGrid', array(
00104 '_current' => true,
00105 'id' => $this->getProductId(),
00106 'product_id' => $this->getProductId(),
00107 ));
00108 }
00109 }