Wyomind_OrdersEraser - Version 1.1.0

Version Notes

none

Download this release

Release Info

Developer Magento Core Team
Extension Wyomind_OrdersEraser
Version 1.1.0
Comparing to
See all releases


Code changes from version 1.0.2 to 1.1.0

app/code/local/Wyomind/DeleteOrders/Block/Grid.php DELETED
@@ -1,241 +0,0 @@
1
- <?php
2
-
3
- class Wyomind_DeleteOrders_Block_Grid extends Mage_Adminhtml_Block_Widget_Grid
4
- {
5
-
6
- public function __construct()
7
- {
8
- parent::__construct();
9
- $this->setId('sales_order_grid');
10
- $this->setUseAjax(true);
11
- $this->setDefaultSort('created_at');
12
- $this->setDefaultDir('DESC');
13
- $this->setSaveParametersInSession(true);
14
- }
15
-
16
- protected function _prepareCollection()
17
- {
18
- //TODO: add full name logic
19
- $collection = Mage::getResourceModel('sales/order_collection')
20
- ->addAttributeToSelect('*')
21
- ->joinAttribute('billing_firstname', 'order_address/firstname', 'billing_address_id', null, 'left')
22
- ->joinAttribute('billing_lastname', 'order_address/lastname', 'billing_address_id', null, 'left')
23
- ->joinAttribute('shipping_firstname', 'order_address/firstname', 'shipping_address_id', null, 'left')
24
- ->joinAttribute('shipping_lastname', 'order_address/lastname', 'shipping_address_id', null, 'left')
25
- ->addExpressionAttributeToSelect('billing_name',
26
- 'CONCAT({{billing_firstname}}, " ", {{billing_lastname}})',
27
- array('billing_firstname', 'billing_lastname'))
28
- ->addExpressionAttributeToSelect('shipping_name',
29
- 'CONCAT({{shipping_firstname}}, " ", {{shipping_lastname}})',
30
- array('shipping_firstname', 'shipping_lastname'));
31
- $this->setCollection($collection);
32
- return parent::_prepareCollection();
33
- }
34
-
35
- protected function _prepareColumns()
36
- {
37
-
38
- $this->addColumn('real_order_id', array(
39
- 'header'=> Mage::helper('sales')->__('Order #'),
40
- 'width' => '80px',
41
- 'type' => 'text',
42
- 'index' => 'increment_id',
43
- ));
44
-
45
- if (!Mage::app()->isSingleStoreMode()) {
46
- $this->addColumn('store_id', array(
47
- 'header' => Mage::helper('sales')->__('Purchased from (store)'),
48
- 'index' => 'store_id',
49
- 'type' => 'store',
50
- 'store_view'=> true,
51
- 'display_deleted' => true,
52
- ));
53
- }
54
-
55
- $this->addColumn('created_at', array(
56
- 'header' => Mage::helper('sales')->__('Purchased On'),
57
- 'index' => 'created_at',
58
- 'type' => 'datetime',
59
- 'width' => '100px',
60
- ));
61
-
62
- /*$this->addColumn('billing_firstname', array(
63
- 'header' => Mage::helper('sales')->__('Bill to First name'),
64
- 'index' => 'billing_firstname',
65
- ));
66
-
67
- $this->addColumn('billing_lastname', array(
68
- 'header' => Mage::helper('sales')->__('Bill to Last name'),
69
- 'index' => 'billing_lastname',
70
- ));*/
71
- $this->addColumn('billing_name', array(
72
- 'header' => Mage::helper('sales')->__('Bill to Name'),
73
- 'index' => 'billing_name',
74
- ));
75
-
76
- /*$this->addColumn('shipping_firstname', array(
77
- 'header' => Mage::helper('sales')->__('Ship to First name'),
78
- 'index' => 'shipping_firstname',
79
- ));
80
-
81
- $this->addColumn('shipping_lastname', array(
82
- 'header' => Mage::helper('sales')->__('Ship to Last name'),
83
- 'index' => 'shipping_lastname',
84
- ));*/
85
- $this->addColumn('shipping_name', array(
86
- 'header' => Mage::helper('sales')->__('Ship to Name'),
87
- 'index' => 'shipping_name',
88
- ));
89
-
90
- $this->addColumn('base_grand_total', array(
91
- 'header' => Mage::helper('sales')->__('G.T. (Base)'),
92
- 'index' => 'base_grand_total',
93
- 'type' => 'currency',
94
- 'currency' => 'base_currency_code',
95
- ));
96
-
97
- $this->addColumn('grand_total', array(
98
- 'header' => Mage::helper('sales')->__('G.T. (Purchased)'),
99
- 'index' => 'grand_total',
100
- 'type' => 'currency',
101
- 'currency' => 'order_currency_code',
102
- ));
103
-
104
- $this->addColumn('status', array(
105
- 'header' => Mage::helper('sales')->__('Status'),
106
- 'index' => 'status',
107
- 'type' => 'options',
108
- 'width' => '70px',
109
- 'options' => Mage::getSingleton('sales/order_config')->getStatuses(),
110
- ));
111
-
112
- if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
113
- $this->addColumn('action',
114
- array(
115
- 'header' => Mage::helper('sales')->__('Action'),
116
- 'width' => '50px',
117
- 'type' => 'action',
118
- 'getter' => 'getId',
119
- 'actions' => array(
120
- array(
121
- 'caption' => Mage::helper('sales')->__('View'),
122
- 'url' => array('base'=>'*/*/view'),
123
- 'field' => 'order_id'
124
- ),
125
- array(
126
- 'caption' => Mage::helper('sales')->__('Delete'),
127
- 'url' => array('base'=>'deleteorders/adminhtml_order/delete'),
128
- 'confirm' => Mage::helper('sales')->__('Are your sure your want to delete this order and to erase all linked data ? '),
129
- 'field' => 'order_id'
130
- )
131
- ),
132
- 'filter' => false,
133
- 'sortable' => false,
134
- 'index' => 'stores',
135
- 'is_system' => true,
136
- ));
137
- }
138
- $this->addRssList('rss/order/new', Mage::helper('sales')->__('New Order RSS'));
139
-
140
- return parent::_prepareColumns();
141
- }
142
-
143
- protected function _prepareMassaction()
144
- {
145
- $this->setMassactionIdField('entity_id');
146
- $this->getMassactionBlock()->setFormFieldName('order_ids');
147
-
148
- $this->getMassactionBlock()->addItem('delete_order', array(
149
- 'label'=> Mage::helper('sales')->__('Delete'),
150
- 'url' => $this->getUrl('deleteorders/adminhtml_order/massdelete'),
151
- ));
152
-
153
-
154
- $this->getMassactionBlock()->addItem('cancel_order', array(
155
- 'label'=> Mage::helper('sales')->__('Cancel'),
156
- 'url' => $this->getUrl('*/*/massCancel'),
157
- ));
158
-
159
- $this->getMassactionBlock()->addItem('hold_order', array(
160
- 'label'=> Mage::helper('sales')->__('Hold'),
161
- 'url' => $this->getUrl('*/*/massHold'),
162
- ));
163
-
164
- $this->getMassactionBlock()->addItem('unhold_order', array(
165
- 'label'=> Mage::helper('sales')->__('Unhold'),
166
- 'url' => $this->getUrl('*/*/massUnhold'),
167
- ));
168
-
169
- $this->getMassactionBlock()->addItem('pdfinvoices_order', array(
170
- 'label'=> Mage::helper('sales')->__('Print Invoices'),
171
- 'url' => $this->getUrl('*/*/pdfinvoices'),
172
- ));
173
-
174
- $this->getMassactionBlock()->addItem('pdfshipments_order', array(
175
- 'label'=> Mage::helper('sales')->__('Print Packingslips'),
176
- 'url' => $this->getUrl('*/*/pdfshipments'),
177
- ));
178
-
179
- $this->getMassactionBlock()->addItem('pdfcreditmemos_order', array(
180
- 'label'=> Mage::helper('sales')->__('Print Credit Memos'),
181
- 'url' => $this->getUrl('*/*/pdfcreditmemos'),
182
- ));
183
-
184
- $this->getMassactionBlock()->addItem('pdfdocs_order', array(
185
- 'label'=> Mage::helper('sales')->__('Print All'),
186
- 'url' => $this->getUrl('*/*/pdfdocs'),
187
- ));
188
-
189
- // $statuses = Mage::getSingleton('sales/order_config')->getStatuses();
190
- // array_unshift($statuses, array('value'=>'', 'label'=>''));
191
- // $this->getMassactionBlock()->addItem('change_status', array(
192
- // 'label'=> Mage::helper('sales')->__('Change Status'),
193
- // 'url' => $this->getUrl('*/*/massStatus'),
194
- // 'additional' => array(
195
- // 'visibility' => array(
196
- // 'name' => 'status',
197
- // 'type' => 'select',
198
- // 'class' => 'required-entry',
199
- // 'label' => Mage::helper('sales')->__('New Status'),
200
- // 'values' => $statuses
201
- // )
202
- // )
203
- // ));
204
-
205
- // $prints = array(
206
- // 'empty' => array('value'=>'', 'label'=>''),
207
- // 'order' => Mage::helper('sales')->__('Orders'),
208
- // 'invoice' => Mage::helper('sales')->__('Invoices'),
209
- // 'shipment' => Mage::helper('sales')->__('Shipments'),
210
- // );
211
- // $this->getMassactionBlock()->addItem('print', array(
212
- // 'label'=> Mage::helper('sales')->__('Print'),
213
- // 'url' => $this->getUrl('*/*/massPrint'),
214
- // 'additional' => array(
215
- // 'visibility' => array(
216
- // 'name' => 'document',
217
- // 'type' => 'select',
218
- // 'class' => 'required-entry',
219
- // 'label' => Mage::helper('sales')->__('Document'),
220
- // 'values' => $prints
221
- // )
222
- // )
223
- // ));
224
-
225
- return $this;
226
- }
227
-
228
- public function getRowUrl($row)
229
- {
230
- if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
231
- return $this->getUrl('*/*/view', array('order_id' => $row->getId()));
232
- }
233
- return false;
234
- }
235
-
236
- public function getGridUrl()
237
- {
238
- return $this->getUrl('*/*/grid', array('_current'=>true));
239
- }
240
-
241
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Wyomind/DeleteOrders/Helper/Data.php DELETED
@@ -1,6 +0,0 @@
1
- <?php
2
-
3
- class Wyomind_DeleteOrders_Helper_Data extends Mage_Core_Helper_Abstract
4
- {
5
-
6
- }
 
 
 
 
 
 
app/code/local/Wyomind/DeleteOrders/Model/Erase.php DELETED
@@ -1,33 +0,0 @@
1
- <?php
2
-
3
-
4
- class Wyomind_DeleteOrders_Model_Erase extends Varien_Object{
5
-
6
- public function _erase($orderId){
7
-
8
- $resource = Mage::getSingleton('core/resource');
9
- $delete= $resource->getConnection('core_read');
10
- $tableSo = $resource->getTableName('sales_order');
11
- $tableSoe = $resource->getTableName('sales_order_entity');
12
- $tableSoei = $resource->getTableName('sales_order_entity_int');
13
- $tableEa = $resource->getTableName('eav_attribute');
14
- $tableSfoi = $resource->getTableName('sales_flat_order_item');
15
-
16
- $sql= "DELETE FROM ".$tableSo." WHERE entity_id = ".$orderId.";";
17
- $delete->query($sql);
18
- $sql="DELETE FROM ".$tableSoe." WHERE parent_id = ".$orderId.";";
19
- $delete->query($sql);
20
- $sql="DELETE s FROM ".$tableSoe." s
21
- JOIN ".$tableSoei." si on s.entity_id = si.entity_id
22
- JOIN ".$tableEa." a on si.attribute_id = a.attribute_id
23
- WHERE a.attribute_code = 'order_id'
24
- AND si.value = ".$orderId.";";
25
- $delete->query($sql);
26
- $sql="DELETE FROM ".$tableSfoi." WHERE order_id=".$orderId.";";
27
- $delete->query($sql);
28
- return true;
29
- }
30
-
31
-
32
- }
33
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Wyomind/DeleteOrders/controllers/adminhtml/OrderController.php DELETED
@@ -1,63 +0,0 @@
1
- <?php
2
- class Wyomind_DeleteOrders_adminhtml_OrderController extends Mage_Adminhtml_Controller_action
3
- {
4
- protected function _initOrder()
5
- {
6
- $id = $this->getRequest()->getParam('order_id');
7
- $order = Mage::getModel('sales/order')->load($id);
8
-
9
- if (!$order->getId()) {
10
- $this->_getSession()->addError($this->__('This order no longer exists.'));
11
- $this->_redirect('adminhtml/sales_order/');
12
- $this->setFlag('', self::FLAG_NO_DISPATCH, true);
13
- return false;
14
- }
15
- Mage::register('sales_order', $order);
16
- Mage::register('current_order', $order);
17
- return $order;
18
- }
19
-
20
- public function massDeleteAction()
21
- {
22
-
23
- $orderIds = $this->getRequest()->getPost('order_ids', array());
24
-
25
-
26
- $countDeleteOrder = 0;
27
- foreach ($orderIds as $orderId) {
28
-
29
- if (Mage::getModel('deleteorders/erase')->_erase($orderId)) {
30
- $countDeleteOrder++;
31
- }
32
- }
33
- if ($countDeleteOrder>0) {
34
- $this->_getSession()->addSuccess($this->__('%s order(s) successfully deleted', $countDeleteOrder));
35
- }
36
- else {
37
-
38
- }
39
- $this->_redirect('adminhtml/sales_order/');
40
- }
41
-
42
- public function deleteAction(){
43
-
44
- if ($order = $this->_initOrder()) {
45
-
46
- try {
47
- Mage::getModel('deleteorders/erase')->_erase($order->getId());
48
- $this->_getSession()->addSuccess(
49
- $this->__('Order was successfully deleted.')
50
- );
51
- }
52
- catch (Mage_Core_Exception $e) {
53
- $this->_getSession()->addError($e->getMessage());
54
- }
55
- catch (Exception $e) {
56
- $this->_getSession()->addError($this->__('Unable to delete order.'));
57
- }
58
- $this->_redirect('adminhtml/sales_order/');
59
- }
60
-
61
- }
62
-
63
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Wyomind/DeleteOrders/etc/config.xml DELETED
@@ -1,65 +0,0 @@
1
- <?xml version="1.0"?>
2
- <!--
3
- /**
4
- * @category Wyomind
5
- * @package Wyomind_DeleteOrders
6
- * @author ModuleCreator
7
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
- */
9
- -->
10
- <config>
11
- <modules>
12
- <Wyomind_DeleteOrders>
13
- <version>1.0.2</version>
14
- </Wyomind_DeleteOrders>
15
- </modules>
16
- <admin>
17
- <routers>
18
- <deleteorders>
19
- <use>admin</use>
20
- <args>
21
- <module>Wyomind_DeleteOrders</module>
22
- <frontName>deleteorders</frontName>
23
- </args>
24
- </deleteorders>
25
- </routers>
26
- </admin>
27
- <global>
28
- <models>
29
- <deleteorders>
30
- <class>Wyomind_DeleteOrders_Model</class>
31
- <resourceModel>deleteorders_mysql4</resourceModel>
32
- </deleteorders>
33
- <deleteorders_mysql4>
34
- <class>Wyomind_DeleteOrders_Model_Mysql4</class>
35
- <entities>
36
- <deleteorders>
37
- <table>deleteorders</table>
38
- </deleteorders>
39
- </entities>
40
- </deleteorders_mysql4>
41
- </models>
42
- <blocks>
43
- <adminhtml>
44
- <rewrite>
45
- <sales_order_grid>Wyomind_DeleteOrders_Block_Grid</sales_order_grid>
46
- </rewrite>
47
- </adminhtml>
48
- </blocks>
49
- <helpers>
50
- <deleteorders>
51
- <class>Wyomind_DeleteOrders_Helper</class>
52
- </deleteorders>
53
- </helpers>
54
-
55
-
56
- </global>
57
-
58
-
59
- </config>
60
-
61
-
62
-
63
-
64
-
65
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Wyomind/Deleteorders/Block/Grid.php ADDED
@@ -0,0 +1 @@
 
0
  public function __construct()
1
  {
2
  parent::__construct();
3
  $this->setId('sales_order_grid');
4
  $this->setUseAjax(true);
5
  $this->setDefaultSort('created_at');
6
  $this->setDefaultDir('DESC');
7
  $this->setSaveParametersInSession(true);
8
  }
9
  /**
10
  * Retrieve collection class
11
  *
12
  * @return string
13
  */
14
  public function getVersion(){
15
  return substr(Mage::getVersion(),0,3);
16
  }
17
 
18
  {
19
 
20
  }
21
  {
22
  return 'sales/order_grid_collection';
23
  }
24
 
25
  {
26
  $this->addColumn('real_order_id', array(
27
  'header'=> Mage::helper('sales')->__('Order #'),
28
  'width' => '80px',
29
  'type' => 'text',
30
  'index' => 'increment_id',
31
  ));
32
  if (!Mage::app()->isSingleStoreMode()) {
33
  $this->addColumn('store_id', array(
34
  'header' => Mage::helper('sales')->__('Purchased From (Store)'),
35
  'index' => 'store_id',
36
  'type' => 'store',
37
  'store_view'=> true,
38
  'display_deleted' => true,
39
  ));
40
  }
41
  $this->addColumn('created_at', array(
42
  'header' => Mage::helper('sales')->__('Purchased On'),
43
  'index' => 'created_at',
44
  'type' => 'datetime',
45
  'width' => '100px',
46
  ));
47
  $this->addColumn('billing_name', array(
48
  'header' => Mage::helper('sales')->__('Bill to Name'),
49
  'index' => 'billing_name',
50
  ));
51
  $this->addColumn('shipping_name', array(
52
  'header' => Mage::helper('sales')->__('Ship to Name'),
53
  'index' => 'shipping_name',
54
  ));
55
  $this->addColumn('base_grand_total', array(
56
  'header' => Mage::helper('sales')->__('G.T. (Base)'),
57
  'index' => 'base_grand_total',
58
  'type' => 'currency',
59
  'currency' => 'base_currency_code',
60
  ));
61
  $this->addColumn('grand_total', array(
62
  'header' => Mage::helper('sales')->__('G.T. (Purchased)'),
63
  'index' => 'grand_total',
64
  'type' => 'currency',
65
  'currency' => 'order_currency_code',
66
  ));
67
  $this->addColumn('status', array(
68
  'header' => Mage::helper('sales')->__('Status'),
69
  'index' => 'status',
70
  'type' => 'options',
71
  'width' => '70px',
72
  'options' => Mage::getSingleton('sales/order_config')->getStatuses(),
73
  ));
74
  if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
75
  $this->addColumn('action',
76
  array(
77
  'header' => Mage::helper('sales')->__('Action'),
78
  'width' => '50px',
79
  'type' => 'action',
80
  'getter' => 'getId',
81
  'actions' => array(
82
  array(
83
  'caption' => Mage::helper('sales')->__('View'),
84
  'url' => array('base'=>'*/sales_order/view'),
85
  'field' => 'order_id'
86
  ),
87
  'caption' => Mage::helper('sales')->__('Delete'),
88
  'url' => array('base'=>'deleteorders/adminhtml_order/delete'),
89
  'confirm' => Mage::helper('sales')->__('Are your sure your want to delete this order and to erase all linked data ? '),
90
  'field' => 'order_id'
91
  )
92
  ),
93
  'filter' => false,
94
  'sortable' => false,
95
  'index' => 'stores',
96
  'is_system' => true,
97
  ));
98
  }
99
  $this->addRssList('rss/order/new', Mage::helper('sales')->__('New Order RSS'));
100
  if($this->getVersion()>1.3){
101
  $this->addExportType('*/*/exportCsv', Mage::helper('sales')->__('CSV'));
102
  $this->addExportType('*/*/exportExcel', Mage::helper('sales')->__('Excel'));
103
  }
104
  return parent::_prepareColumns();
105
  }
106
  protected function _prepareMassaction()
107
  {
108
  $this->setMassactionIdField('entity_id');
109
  $this->getMassactionBlock()->setFormFieldName('order_ids');
110
  $this->getMassactionBlock()->setUseSelectAll(false);
111
  'label'=> Mage::helper('sales')->__('Delete'),
112
  'url' => $this->getUrl('deleteorders/adminhtml_order/massdelete'),
113
  ));
114
 
115
  $this->getMassactionBlock()->addItem('cancel_order', array(
116
  'label'=> Mage::helper('sales')->__('Cancel'),
117
  'url' => $this->getUrl('*/sales_order/massCancel'),
118
  ));
119
  }
120
  if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/hold')) {
121
  $this->getMassactionBlock()->addItem('hold_order', array(
122
  'label'=> Mage::helper('sales')->__('Hold'),
123
  'url' => $this->getUrl('*/sales_order/massHold'),
124
  ));
125
  }
126
  if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/unhold')) {
127
  $this->getMassactionBlock()->addItem('unhold_order', array(
128
  'label'=> Mage::helper('sales')->__('Unhold'),
129
  'url' => $this->getUrl('*/sales_order/massUnhold'),
130
  ));
131
  }
132
  $this->getMassactionBlock()->addItem('pdfinvoices_order', array(
133
  'label'=> Mage::helper('sales')->__('Print Invoices'),
134
  'url' => $this->getUrl('*/sales_order/pdfinvoices'),
135
  ));
136
  $this->getMassactionBlock()->addItem('pdfshipments_order', array(
137
  'label'=> Mage::helper('sales')->__('Print Packingslips'),
138
  'url' => $this->getUrl('*/sales_order/pdfshipments'),
139
  ));
140
  $this->getMassactionBlock()->addItem('pdfcreditmemos_order', array(
141
  'label'=> Mage::helper('sales')->__('Print Credit Memos'),
142
  'url' => $this->getUrl('*/sales_order/pdfcreditmemos'),
143
  ));
144
  $this->getMassactionBlock()->addItem('pdfdocs_order', array(
145
  'label'=> Mage::helper('sales')->__('Print All'),
146
  'url' => $this->getUrl('*/sales_order/pdfdocs'),
147
  ));
148
  return $this;
149
  }
150
  public function getRowUrl($row)
151
  {
152
  if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
153
  return $this->getUrl('*/sales_order/view', array('order_id' => $row->getId()));
154
  }
155
  return false;
156
  }
157
  public function getGridUrl()
158
  {
159
  return $this->getUrl('*/*/grid', array('_current'=>true));
160
  }
1
+ <?php
2
  public function __construct()
3
  {
4
  parent::__construct();
5
  $this->setId('sales_order_grid');
6
  $this->setUseAjax(true);
7
  $this->setDefaultSort('created_at');
8
  $this->setDefaultDir('DESC');
9
  $this->setSaveParametersInSession(true);
10
  }
11
  /**
12
  * Retrieve collection class
13
  *
14
  * @return string
15
  */
16
  public function getVersion(){
17
  return substr(Mage::getVersion(),0,3);
18
  }
19
 
20
  {
21
 
22
  }
23
  {
24
  return 'sales/order_grid_collection';
25
  }
26
 
27
  {
28
  $this->addColumn('real_order_id', array(
29
  'header'=> Mage::helper('sales')->__('Order #'),
30
  'width' => '80px',
31
  'type' => 'text',
32
  'index' => 'increment_id',
33
  ));
34
  if (!Mage::app()->isSingleStoreMode()) {
35
  $this->addColumn('store_id', array(
36
  'header' => Mage::helper('sales')->__('Purchased From (Store)'),
37
  'index' => 'store_id',
38
  'type' => 'store',
39
  'store_view'=> true,
40
  'display_deleted' => true,
41
  ));
42
  }
43
  $this->addColumn('created_at', array(
44
  'header' => Mage::helper('sales')->__('Purchased On'),
45
  'index' => 'created_at',
46
  'type' => 'datetime',
47
  'width' => '100px',
48
  ));
49
  $this->addColumn('billing_name', array(
50
  'header' => Mage::helper('sales')->__('Bill to Name'),
51
  'index' => 'billing_name',
52
  ));
53
  $this->addColumn('shipping_name', array(
54
  'header' => Mage::helper('sales')->__('Ship to Name'),
55
  'index' => 'shipping_name',
56
  ));
57
  $this->addColumn('base_grand_total', array(
58
  'header' => Mage::helper('sales')->__('G.T. (Base)'),
59
  'index' => 'base_grand_total',
60
  'type' => 'currency',
61
  'currency' => 'base_currency_code',
62
  ));
63
  $this->addColumn('grand_total', array(
64
  'header' => Mage::helper('sales')->__('G.T. (Purchased)'),
65
  'index' => 'grand_total',
66
  'type' => 'currency',
67
  'currency' => 'order_currency_code',
68
  ));
69
  $this->addColumn('status', array(
70
  'header' => Mage::helper('sales')->__('Status'),
71
  'index' => 'status',
72
  'type' => 'options',
73
  'width' => '70px',
74
  'options' => Mage::getSingleton('sales/order_config')->getStatuses(),
75
  ));
76
  if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
77
  $this->addColumn('action',
78
  array(
79
  'header' => Mage::helper('sales')->__('Action'),
80
  'width' => '50px',
81
  'type' => 'action',
82
  'getter' => 'getId',
83
  'actions' => array(
84
  array(
85
  'caption' => Mage::helper('sales')->__('View'),
86
  'url' => array('base'=>'*/sales_order/view'),
87
  'field' => 'order_id'
88
  ),
89
  'caption' => Mage::helper('sales')->__('Delete'),
90
  'url' => array('base'=>'deleteorders/adminhtml_order/delete'),
91
  'confirm' => Mage::helper('sales')->__('Are your sure your want to delete this order and to erase all linked data ? '),
92
  'field' => 'order_id'
93
  )
94
  ),
95
  'filter' => false,
96
  'sortable' => false,
97
  'index' => 'stores',
98
  'is_system' => true,
99
  ));
100
  }
101
  $this->addRssList('rss/order/new', Mage::helper('sales')->__('New Order RSS'));
102
  if($this->getVersion()>1.3){
103
  $this->addExportType('*/*/exportCsv', Mage::helper('sales')->__('CSV'));
104
  $this->addExportType('*/*/exportExcel', Mage::helper('sales')->__('Excel'));
105
  }
106
  return parent::_prepareColumns();
107
  }
108
  protected function _prepareMassaction()
109
  {
110
  $this->setMassactionIdField('entity_id');
111
  $this->getMassactionBlock()->setFormFieldName('order_ids');
112
  $this->getMassactionBlock()->setUseSelectAll(false);
113
  'label'=> Mage::helper('sales')->__('Delete'),
114
  'url' => $this->getUrl('deleteorders/adminhtml_order/massdelete'),
115
  ));
116
 
117
  $this->getMassactionBlock()->addItem('cancel_order', array(
118
  'label'=> Mage::helper('sales')->__('Cancel'),
119
  'url' => $this->getUrl('*/sales_order/massCancel'),
120
  ));
121
  }
122
  if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/hold')) {
123
  $this->getMassactionBlock()->addItem('hold_order', array(
124
  'label'=> Mage::helper('sales')->__('Hold'),
125
  'url' => $this->getUrl('*/sales_order/massHold'),
126
  ));
127
  }
128
  if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/unhold')) {
129
  $this->getMassactionBlock()->addItem('unhold_order', array(
130
  'label'=> Mage::helper('sales')->__('Unhold'),
131
  'url' => $this->getUrl('*/sales_order/massUnhold'),
132
  ));
133
  }
134
  $this->getMassactionBlock()->addItem('pdfinvoices_order', array(
135
  'label'=> Mage::helper('sales')->__('Print Invoices'),
136
  'url' => $this->getUrl('*/sales_order/pdfinvoices'),
137
  ));
138
  $this->getMassactionBlock()->addItem('pdfshipments_order', array(
139
  'label'=> Mage::helper('sales')->__('Print Packingslips'),
140
  'url' => $this->getUrl('*/sales_order/pdfshipments'),
141
  ));
142
  $this->getMassactionBlock()->addItem('pdfcreditmemos_order', array(
143
  'label'=> Mage::helper('sales')->__('Print Credit Memos'),
144
  'url' => $this->getUrl('*/sales_order/pdfcreditmemos'),
145
  ));
146
  $this->getMassactionBlock()->addItem('pdfdocs_order', array(
147
  'label'=> Mage::helper('sales')->__('Print All'),
148
  'url' => $this->getUrl('*/sales_order/pdfdocs'),
149
  ));
150
  return $this;
151
  }
152
  public function getRowUrl($row)
153
  {
154
  if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
155
  return $this->getUrl('*/sales_order/view', array('order_id' => $row->getId()));
156
  }
157
  return false;
158
  }
159
  public function getGridUrl()
160
  {
161
  return $this->getUrl('*/*/grid', array('_current'=>true));
162
  }
app/code/local/Wyomind/Deleteorders/Helper/Data.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Wyomind_Deleteorders_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+
6
+ }
app/code/local/Wyomind/Deleteorders/Model/Erase.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class Wyomind_DeleteOrders_Model_Erase extends Varien_Object{
5
+
6
+ public function _erase($orderId){
7
+ $resource = Mage::getSingleton('core/resource');
8
+ $sql="DELETE FROM ".$tableSoe." WHERE parent_id = ".$orderId.";";
9
+ $delete->query($sql);
10
+ $sql="DELETE s FROM ".$tableSoe." s
11
+ JOIN ".$tableSoei." si on s.entity_id = si.entity_id
12
+ JOIN ".$tableEa." a on si.attribute_id = a.attribute_id
13
+ WHERE a.attribute_code = 'order_id'
14
+ AND si.value = ".$orderId.";";
15
+ $delete->query($sql);
16
+ return true;
17
+ }
18
+ }
19
+
app/code/local/Wyomind/Deleteorders/controllers/Adminhtml/OrderController.php ADDED
@@ -0,0 +1,5 @@
 
 
0
  return substr(Mage::getVersion(),0,3);
 
 
1
  $id = $this->getRequest()->getParam('order_id');
2
  $order = Mage::getModel('sales/order')->load($id);
3
  if (!$order->getId()) {
4
  $this->_getSession()->addError($this->__('This order no longer exists.'));
5
  $this->_redirect('adminhtml/sales_order/');
6
  $this->setFlag('', self::FLAG_NO_DISPATCH, true);
7
  return false;
8
  }
9
  Mage::register('sales_order', $order);
10
  Mage::register('current_order', $order);
11
  return $order;
12
  }
13
  {
14
  $orderIds = $this->getRequest()->getPost('order_ids', array());
15
  $countDeleteOrder = 0;
16
  foreach ($orderIds as $orderId) {
17
  if ( $this->getVersion()<=1.3 && Mage::getModel('deleteorders/erase')->_erase($orderId)) $countDeleteOrder++;
18
  elseif($order->delete()) $countDeleteOrder++;
19
  }
20
  if ($countDeleteOrder>0) {
21
  $this->_getSession()->addSuccess($this->__('%s order(s) successfully deleted', $countDeleteOrder));
22
  }
23
  else {
24
  }
25
  $this->_redirect('adminhtml/sales_order/');
26
  }
 
27
  try {
28
 
29
  if ( $this->getVersion()<=1.3) Mage::getModel('deleteorders/erase')->_erase($order->getId());
30
  $this->__('Order was successfully deleted.')
31
  );
32
  }
33
  catch (Mage_Core_Exception $e) {
34
  $this->_getSession()->addError($e->getMessage());
35
  }
36
  catch (Exception $e) {
37
  $this->_getSession()->addError($this->__('Unable to delete order.'));
38
  }
39
  $this->_redirect('adminhtml/sales_order/');
40
  }
1
+ <?php
2
+ {
3
  return substr(Mage::getVersion(),0,3);
4
+ protected function _initOrder()
5
+ {
6
  $id = $this->getRequest()->getParam('order_id');
7
  $order = Mage::getModel('sales/order')->load($id);
8
  if (!$order->getId()) {
9
  $this->_getSession()->addError($this->__('This order no longer exists.'));
10
  $this->_redirect('adminhtml/sales_order/');
11
  $this->setFlag('', self::FLAG_NO_DISPATCH, true);
12
  return false;
13
  }
14
  Mage::register('sales_order', $order);
15
  Mage::register('current_order', $order);
16
  return $order;
17
  }
18
  {
19
  $orderIds = $this->getRequest()->getPost('order_ids', array());
20
  $countDeleteOrder = 0;
21
  foreach ($orderIds as $orderId) {
22
  if ( $this->getVersion()<=1.3 && Mage::getModel('deleteorders/erase')->_erase($orderId)) $countDeleteOrder++;
23
  elseif($order->delete()) $countDeleteOrder++;
24
  }
25
  if ($countDeleteOrder>0) {
26
  $this->_getSession()->addSuccess($this->__('%s order(s) successfully deleted', $countDeleteOrder));
27
  }
28
  else {
29
  }
30
  $this->_redirect('adminhtml/sales_order/');
31
  }
32
+ if ($order = $this->_initOrder()) {
33
  try {
34
 
35
  if ( $this->getVersion()<=1.3) Mage::getModel('deleteorders/erase')->_erase($order->getId());
36
  $this->__('Order was successfully deleted.')
37
  );
38
  }
39
  catch (Mage_Core_Exception $e) {
40
  $this->_getSession()->addError($e->getMessage());
41
  }
42
  catch (Exception $e) {
43
  $this->_getSession()->addError($this->__('Unable to delete order.'));
44
  }
45
  $this->_redirect('adminhtml/sales_order/');
46
  }
app/code/local/Wyomind/Deleteorders/etc/config.xml ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category Wyomind
5
+ * @package Wyomind_DeleteOrders
6
+ * @author ModuleCreator
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ -->
10
+ <config>
11
+ <modules>
12
+ <Wyomind_Deleteorders>
13
+ <version>1.1.0</version>
14
+ </Wyomind_Deleteorders>
15
+ </modules>
16
+ <admin>
17
+ <routers>
18
+ <deleteorders>
19
+ <use>admin</use>
20
+ <args>
21
+ <module>Wyomind_Deleteorders</module>
22
+ <frontName>deleteorders</frontName>
23
+ </args>
24
+ </deleteorders>
25
+ </routers>
26
+ </admin>
27
+ <adminhtml>
28
+
29
+ <acl>
30
+ <resources>
31
+ <all>
32
+ <title>Allow Everything</title>
33
+ </all>
34
+ <admin>
35
+ <children>
36
+ <sales>
37
+ <children>
38
+ <order>
39
+ <children>
40
+ <actions>
41
+ <children>
42
+ <delete translate="title">
43
+ <title>Delete (Orders Eraser)</title>
44
+ </delete>
45
+ </children>
46
+ </actions>
47
+ </children>
48
+ </order>
49
+ </children>
50
+ </sales>
51
+ </children>
52
+ </admin>
53
+ </resources>
54
+ </acl>
55
+ </adminhtml>
56
+ <global>
57
+ <models>
58
+ <deleteorders>
59
+ <class>Wyomind_Deleteorders_Model</class>
60
+ <resourceModel>deleteorders_mysql4</resourceModel>
61
+ </deleteorders>
62
+ <deleteorders_mysql4>
63
+ <class>Wyomind_Deleteorders_Model_Mysql4</class>
64
+ <entities>
65
+ <deleteorders>
66
+ <table>deleteorders</table>
67
+ </deleteorders>
68
+ </entities>
69
+ </deleteorders_mysql4>
70
+ </models>
71
+ <deleteorders_setup>
72
+ <setup>
73
+ <module>Wyomind_Deleteorders</module>
74
+ </setup>
75
+ <connection>
76
+ <use>core_setup</use>
77
+ </connection>
78
+ </deleteorders_setup>
79
+ <deleteorders_write>
80
+ <connection>
81
+ <use>core_write</use>
82
+ </connection>
83
+ </deleteorders_write>
84
+ <deleteorders_read>
85
+ <connection>
86
+ <use>core_read</use>
87
+ </connection>
88
+ </deleteorders_read>
89
+ </resources>
90
+ <blocks>
91
+ <adminhtml>
92
+ <rewrite>
93
+ <sales_order_grid>Wyomind_Deleteorders_Block_Grid</sales_order_grid>
94
+ </rewrite>
95
+ </adminhtml>
96
+ </blocks>
97
+ <helpers>
98
+ <deleteorders>
99
+ <class>Wyomind_Deleteorders_Helper</class>
100
+ </deleteorders>
101
+ </helpers>
102
+
103
+
104
+ </global>
105
+
106
+
107
+ </config>
108
+
109
+
110
+
111
+
112
+
113
+
app/etc/modules/{Wyomind_DeleteOrders.xml → Wyomind_Deleteorders.xml} RENAMED
@@ -1,17 +1,17 @@
1
- <?xml version="1.0"?>
2
- <!--
3
- /**
4
- * @category Wyomind
5
- * @package Wyomind_DeleteOrders
6
- * @author ModuleCreator
7
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
- */
9
- -->
10
- <config>
11
- <modules>
12
- <Wyomind_DeleteOrders>
13
- <active>true</active>
14
- <codePool>local</codePool>
15
- </Wyomind_DeleteOrders>
16
- </modules>
17
  </config>
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category Wyomind
5
+ * @package Wyomind_DeleteOrders
6
+ * @author ModuleCreator
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ -->
10
+ <config>
11
+ <modules>
12
+ <Wyomind_Deleteorders>
13
+ <active>true</active>
14
+ <codePool>local</codePool>
15
+ </Wyomind_Deleteorders>
16
+ </modules>
17
  </config>
package.xml CHANGED
@@ -1,8 +1,8 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Wyomind_OrdersEraser</name>
4
- <version>1.0.2</version>
5
- <stability>stable</stability>
6
  <license>GPL</license>
7
  <channel>community</channel>
8
  <extends/>
@@ -10,9 +10,9 @@
10
  <description>Delete Orders add an option in order panel to clean database and to delete old or canceled orders.</description>
11
  <notes>none</notes>
12
  <authors><author><name>Pierre</name><user>auto-converted</user><email>contact@wyomind.com</email></author></authors>
13
- <date>2011-03-09</date>
14
- <time>08:46:08</time>
15
- <contents><target name="magelocal"><dir name="Wyomind"><dir name="DeleteOrders"><dir name="Block"><file name="Grid.php" hash="6a8080cc1a20eb569b8eed2111de3fa6"/></dir><dir name="controllers"><dir name="adminhtml"><file name="OrderController.php" hash="a3c41bba1516ab90bdcd3d46b85f4115"/></dir></dir><dir name="etc"><file name="config.xml" hash="7551a4192129a2f4229cd8dd94c518c5"/></dir><dir name="Helper"><file name="Data.php" hash="e0e0560c5e57215aee50512e3bd0cc4c"/></dir><dir name="Model"><file name="Erase.php" hash="32a6659394c8f4e3c18dd867fb11ad88"/></dir></dir></dir></target><target name="mage"><dir><dir name="app"><dir name="etc"><dir name="modules"><file name="Wyomind_DeleteOrders.xml" hash="1dd1fdadd5f5e213e48d06c76602ad40"/></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies/>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Wyomind_OrdersEraser</name>
4
+ <version>1.1.0</version>
5
+ <stability>beta</stability>
6
  <license>GPL</license>
7
  <channel>community</channel>
8
  <extends/>
10
  <description>Delete Orders add an option in order panel to clean database and to delete old or canceled orders.</description>
11
  <notes>none</notes>
12
  <authors><author><name>Pierre</name><user>auto-converted</user><email>contact@wyomind.com</email></author></authors>
13
+ <date>2011-03-10</date>
14
+ <time>15:06:07</time>
15
+ <contents><target name="magelocal"><dir name="Wyomind"><dir name="Deleteorders"><dir name="Block"><file name="Grid.php" hash="dc26952510bcb553be5644f36ae10b08"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="OrderController.php" hash="88ff1bde16e7ab961632552a1558eb30"/></dir></dir><dir name="etc"><file name="config.xml" hash="4d593aa5b632223797f25649da8b2286"/></dir><dir name="Helper"><file name="Data.php" hash="ce0049fb8c2f61e5496f7ff007906fcf"/></dir><dir name="Model"><file name="Erase.php" hash="133d95683b1512f2fe2c5885fb57a01f"/></dir></dir></dir></target><target name="mage"><dir><dir name="app"><dir name="etc"><dir name="modules"><file name="Wyomind_Deleteorders.xml" hash="add16f3c44d440af01b4bdd5eb4e84ad"/></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies/>
18
  </package>