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_Promo_Catalog_Grid extends Mage_Adminhtml_Block_Widget_Grid
35: {
36: 37: 38: 39:
40: public function __construct()
41: {
42: parent::__construct();
43: $this->setId('promo_catalog_grid');
44: $this->setDefaultSort('name');
45: $this->setDefaultDir('ASC');
46: $this->setSaveParametersInSession(true);
47: }
48:
49: 50: 51: 52: 53: 54:
55: protected function _prepareCollection()
56: {
57:
58: $collection = Mage::getModel('catalogrule/rule')
59: ->getResourceCollection();
60: $collection->addWebsitesToResult();
61: $this->setCollection($collection);
62:
63: parent::_prepareCollection();
64: return $this;
65: }
66:
67: 68: 69: 70: 71:
72: protected function _prepareColumns()
73: {
74: $this->addColumn('rule_id', array(
75: 'header' => Mage::helper('catalogrule')->__('ID'),
76: 'align' =>'right',
77: 'width' => '50px',
78: 'index' => 'rule_id',
79: ));
80:
81: $this->addColumn('name', array(
82: 'header' => Mage::helper('catalogrule')->__('Rule Name'),
83: 'align' =>'left',
84: 'index' => 'name',
85: ));
86:
87: $this->addColumn('from_date', array(
88: 'header' => Mage::helper('catalogrule')->__('Date Start'),
89: 'align' => 'left',
90: 'width' => '120px',
91: 'type' => 'date',
92: 'index' => 'from_date',
93: ));
94:
95: $this->addColumn('to_date', array(
96: 'header' => Mage::helper('catalogrule')->__('Date Expire'),
97: 'align' => 'left',
98: 'width' => '120px',
99: 'type' => 'date',
100: 'default' => '--',
101: 'index' => 'to_date',
102: ));
103:
104: $this->addColumn('is_active', array(
105: 'header' => Mage::helper('catalogrule')->__('Status'),
106: 'align' => 'left',
107: 'width' => '80px',
108: 'index' => 'is_active',
109: 'type' => 'options',
110: 'options' => array(
111: 1 => Mage::helper('catalogrule')->__('Active'),
112: 0 => Mage::helper('catalogrule')->__('Inactive')
113: ),
114: ));
115:
116: if (!Mage::app()->isSingleStoreMode()) {
117: $this->addColumn('rule_website', array(
118: 'header' => Mage::helper('catalogrule')->__('Website'),
119: 'align' =>'left',
120: 'index' => 'website_ids',
121: 'type' => 'options',
122: 'sortable' => false,
123: 'options' => Mage::getSingleton('adminhtml/system_store')->getWebsiteOptionHash(),
124: 'width' => 200,
125: ));
126: }
127:
128: parent::_prepareColumns();
129: return $this;
130: }
131:
132: 133: 134: 135: 136: 137: 138:
139: public function getRowUrl($row)
140: {
141: return $this->getUrl('*/*/edit', array('id' => $row->getRuleId()));
142: }
143:
144: }
145: