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_Report_Shopcart_Abandoned_Grid extends Mage_Adminhtml_Block_Report_Grid_Shopcart
35: {
36:
37: public function __construct()
38: {
39: parent::__construct();
40: $this->setId('gridAbandoned');
41: }
42:
43: protected function _prepareCollection()
44: {
45:
46: $collection = Mage::getResourceModel('reports/quote_collection');
47:
48: $filter = $this->getParam($this->getVarNameFilter(), array());
49: if ($filter) {
50: $filter = base64_decode($filter);
51: parse_str(urldecode($filter), $data);
52: }
53:
54: if (!empty($data)) {
55: $collection->prepareForAbandonedReport($this->_storeIds, $data);
56: } else {
57: $collection->prepareForAbandonedReport($this->_storeIds);
58: }
59:
60: $this->setCollection($collection);
61: return parent::_prepareCollection();
62: }
63:
64: protected function _addColumnFilterToCollection($column)
65: {
66: $field = ( $column->getFilterIndex() ) ? $column->getFilterIndex() : $column->getIndex();
67: $skip = array('subtotal', 'customer_name', 'email');
68:
69: if (in_array($field, $skip)) {
70: return $this;
71: }
72:
73: parent::_addColumnFilterToCollection($column);
74: return $this;
75: }
76:
77: protected function _prepareColumns()
78: {
79: $this->addColumn('customer_name', array(
80: 'header' =>Mage::helper('reports')->__('Customer Name'),
81: 'index' =>'customer_name',
82: 'sortable' =>false
83: ));
84:
85: $this->addColumn('email', array(
86: 'header' =>Mage::helper('reports')->__('Email'),
87: 'index' =>'email',
88: 'sortable' =>false
89: ));
90:
91: $this->addColumn('items_count', array(
92: 'header' =>Mage::helper('reports')->__('Number of Items'),
93: 'width' =>'80px',
94: 'align' =>'right',
95: 'index' =>'items_count',
96: 'sortable' =>false,
97: 'type' =>'number'
98: ));
99:
100: $this->addColumn('items_qty', array(
101: 'header' =>Mage::helper('reports')->__('Quantity of Items'),
102: 'width' =>'80px',
103: 'align' =>'right',
104: 'index' =>'items_qty',
105: 'sortable' =>false,
106: 'type' =>'number'
107: ));
108:
109: if ($this->getRequest()->getParam('website')) {
110: $storeIds = Mage::app()->getWebsite($this->getRequest()->getParam('website'))->getStoreIds();
111: } else if ($this->getRequest()->getParam('group')) {
112: $storeIds = Mage::app()->getGroup($this->getRequest()->getParam('group'))->getStoreIds();
113: } else if ($this->getRequest()->getParam('store')) {
114: $storeIds = array((int)$this->getRequest()->getParam('store'));
115: } else {
116: $storeIds = array();
117: }
118: $this->setStoreIds($storeIds);
119: $currencyCode = $this->getCurrentCurrencyCode();
120:
121: $this->addColumn('subtotal', array(
122: 'header' => Mage::helper('reports')->__('Subtotal'),
123: 'width' => '80px',
124: 'type' => 'currency',
125: 'currency_code' => $currencyCode,
126: 'index' => 'subtotal',
127: 'sortable' => false,
128: 'renderer' => 'adminhtml/report_grid_column_renderer_currency',
129: 'rate' => $this->getRate($currencyCode),
130: ));
131:
132: $this->addColumn('coupon_code', array(
133: 'header' =>Mage::helper('reports')->__('Applied Coupon'),
134: 'width' =>'80px',
135: 'index' =>'coupon_code',
136: 'sortable' =>false
137: ));
138:
139: $this->addColumn('created_at', array(
140: 'header' =>Mage::helper('reports')->__('Created At'),
141: 'width' =>'170px',
142: 'type' =>'datetime',
143: 'index' =>'created_at',
144: 'filter_index'=>'main_table.created_at',
145: 'sortable' =>false
146: ));
147:
148: $this->addColumn('updated_at', array(
149: 'header' =>Mage::helper('reports')->__('Updated At'),
150: 'width' =>'170px',
151: 'type' =>'datetime',
152: 'index' =>'updated_at',
153: 'filter_index'=>'main_table.updated_at',
154: 'sortable' =>false
155: ));
156:
157: $this->addColumn('remote_ip', array(
158: 'header' =>Mage::helper('reports')->__('IP Address'),
159: 'width' =>'80px',
160: 'index' =>'remote_ip',
161: 'sortable' =>false
162: ));
163:
164: $this->addExportType('*/*/exportAbandonedCsv', Mage::helper('reports')->__('CSV'));
165: $this->addExportType('*/*/exportAbandonedExcel', Mage::helper('reports')->__('Excel XML'));
166:
167: return parent::_prepareColumns();
168: }
169:
170: public function getRowUrl($row)
171: {
172: return $this->getUrl('*/customer/edit', array('id'=>$row->getCustomerId(), 'active_tab'=>'cart'));
173: }
174: }
175: