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_GoogleBase_Block_Adminhtml_Items_Item extends Mage_Adminhtml_Block_Widget_Grid
35: {
36: public function __construct()
37: {
38: parent::__construct();
39: $this->setId('items');
40: $this->setUseAjax(true);
41: }
42:
43: protected function _prepareCollection()
44: {
45: $collection = Mage::getResourceModel('googlebase/item_collection');
46: $store = $this->_getStore();
47: $collection->addStoreFilterId($store->getId());
48: $this->setCollection($collection);
49: parent::_prepareCollection();
50: return $this;
51: }
52:
53: protected function _prepareColumns()
54: {
55: $this->addColumn('name',
56: array(
57: 'header' => $this->__('Product Name'),
58: 'width' => '30%',
59: 'index' => 'name',
60: ));
61:
62: $this->addColumn('gbase_item_id',
63: array(
64: 'header' => $this->__('Google Base ID'),
65: 'width' => '150px',
66: 'index' => 'gbase_item_id',
67: 'renderer' => 'googlebase/adminhtml_items_renderer_id',
68:
69: ));
70:
71: $this->addColumn('gbase_itemtype',
72: array(
73: 'header' => $this->__('Google Base Item Type'),
74: 'width' => '150px',
75: 'index' => 'gbase_itemtype',
76: ));
77:
78:
79:
80:
81:
82:
83:
84:
85:
86: $this->addColumn('expires',
87: array(
88: 'header' => $this->__('Expires'),
89: 'type' => 'datetime',
90: 'width' => '100px',
91: 'index' => 'expires',
92: ));
93:
94: $this->addColumn('impr',
95: array(
96: 'header' => $this->__('Impr.'),
97: 'width' => '150px',
98: 'index' => 'impr',
99: 'filter' => false,
100: ));
101:
102: $this->addColumn('clicks',
103: array(
104: 'header' => $this->__('Clicks'),
105: 'width' => '150px',
106: 'index' => 'clicks',
107: 'filter' => false,
108: ));
109:
110: $this->addColumn('active',
111: array(
112: 'header' => $this->__('Active'),
113: 'width' => '150px',
114: 'type' => 'options',
115: 'width' => '70px',
116: 'options' => Mage::getSingleton('googlebase/source_statuses')->getStatuses(),
117: 'index' => 'is_hidden',
118: ));
119:
120: return parent::_prepareColumns();
121: }
122:
123: protected function _prepareMassaction()
124: {
125: $this->setMassactionIdField('item_id');
126: $this->getMassactionBlock()->setFormFieldName('item');
127: $this->setNoFilterMassactionColumn(true);
128:
129: $this->getMassactionBlock()->addItem('delete', array(
130: 'label' => $this->__('Delete'),
131: 'url' => $this->getUrl('*/*/massDelete', array('_current' => true)),
132: 'confirm' => $this->__('Are you sure?')
133: ));
134:
135: $this->getMassactionBlock()->addItem('publish', array(
136: 'label' => $this->__('Publish'),
137: 'url' => $this->getUrl('*/*/massPublish', array('_current' => true))
138: ));
139:
140: $this->getMassactionBlock()->addItem('unpublish', array(
141: 'label' => $this->__('Hide'),
142: 'url' => $this->getUrl('*/*/massHide', array('_current' => true))
143: ));
144:
145: $this->getMassactionBlock()->addItem('refresh', array(
146: 'label' => $this->__('Synchronize'),
147: 'url' => $this->getUrl('*/*/refresh', array('_current' => true)),
148: 'confirm' => $this->__('This action will update items statistics and remove the items which are not available in Google Base. Continue?')
149: ));
150: return $this;
151: }
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175: public function getGridUrl()
176: {
177: return $this->getUrl('*/*/grid', array('_current' => true));
178: }
179:
180: protected function _getStore()
181: {
182: return Mage::app()->getStore($this->getRequest()->getParam('store'));
183: }
184: }
185: