SiteClue_Delete_Orders - Version 1.0.0

Version Notes

Simple tool for deleting Magento order extension. Single order delete and mass order delete features.

Download this release

Release Info

Developer Site Clue
Extension SiteClue_Delete_Orders
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

app/code/community/SiteClue/Deleteorder/Block/Adminhtml/Sales/Order/Grid.php ADDED
@@ -0,0 +1,190 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SiteClue
4
+ * @category SiteClue
5
+ * @package SiteClue_Deleteorder
6
+ * @copyright Copyright (c) 2015-2016 SiteClue. (http://www.siteclue.com)
7
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
8
+ */
9
+
10
+ class SiteClue_Deleteorder_Block_Adminhtml_Sales_Order_Grid extends Mage_Adminhtml_Block_Widget_Grid
11
+ {
12
+ public function __construct()
13
+ {
14
+ parent::__construct();
15
+ $this->setId('sales_order_grid');
16
+ $this->setUseAjax(true);
17
+ $this->setDefaultSort('created_at');
18
+ $this->setDefaultDir('DESC');
19
+ $this->setSaveParametersInSession(true);
20
+ }
21
+
22
+
23
+ protected function _getCollectionClass()
24
+ {
25
+ return 'sales/order_grid_collection';
26
+ }
27
+
28
+ protected function _prepareCollection()
29
+ {
30
+ $collection = Mage::getResourceModel($this->_getCollectionClass());
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_name', array(
63
+ 'header' => Mage::helper('sales')->__('Bill to Name'),
64
+ 'index' => 'billing_name',
65
+ ));
66
+
67
+ $this->addColumn('shipping_name', array(
68
+ 'header' => Mage::helper('sales')->__('Ship to Name'),
69
+ 'index' => 'shipping_name',
70
+ ));
71
+
72
+ $this->addColumn('base_grand_total', array(
73
+ 'header' => Mage::helper('sales')->__('G.T. (Base)'),
74
+ 'index' => 'base_grand_total',
75
+ 'type' => 'currency',
76
+ 'currency' => 'base_currency_code',
77
+ ));
78
+
79
+ $this->addColumn('grand_total', array(
80
+ 'header' => Mage::helper('sales')->__('G.T. (Purchased)'),
81
+ 'index' => 'grand_total',
82
+ 'type' => 'currency',
83
+ 'currency' => 'order_currency_code',
84
+ ));
85
+
86
+ $this->addColumn('status', array(
87
+ 'header' => Mage::helper('sales')->__('Status'),
88
+ 'index' => 'status',
89
+ 'type' => 'options',
90
+ 'width' => '70px',
91
+ 'options' => Mage::getSingleton('sales/order_config')->getStatuses(),
92
+ ));
93
+
94
+ if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
95
+ $this->addColumn('action',
96
+ array(
97
+ 'header' => Mage::helper('sales')->__('Action'),
98
+ 'width' => '100px',
99
+ 'type' => 'action',
100
+ 'getter' => 'getId',
101
+ 'renderer' => 'deleteorder/adminhtml_sales_order_render_delete',
102
+ 'filter' => false,
103
+ 'sortable' => false,
104
+ 'index' => 'stores',
105
+ 'is_system' => true,
106
+ ));
107
+ }
108
+ $this->addRssList('rss/order/new', Mage::helper('sales')->__('New Order RSS'));
109
+
110
+ $this->addExportType('*/*/exportCsv', Mage::helper('sales')->__('CSV'));
111
+ $this->addExportType('*/*/exportExcel', Mage::helper('sales')->__('Excel XML'));
112
+
113
+ return parent::_prepareColumns();
114
+ }
115
+
116
+ protected function _prepareMassaction()
117
+ {
118
+ $this->setMassactionIdField('entity_id');
119
+ $this->getMassactionBlock()->setFormFieldName('order_ids');
120
+ $this->getMassactionBlock()->setUseSelectAll(false);
121
+
122
+ if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/cancel')) {
123
+ $this->getMassactionBlock()->addItem('cancel_order', array(
124
+ 'label'=> Mage::helper('sales')->__('Cancel'),
125
+ 'url' => $this->getUrl('*/sales_order/massCancel'),
126
+ ));
127
+ }
128
+
129
+ if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/hold')) {
130
+ $this->getMassactionBlock()->addItem('hold_order', array(
131
+ 'label'=> Mage::helper('sales')->__('Hold'),
132
+ 'url' => $this->getUrl('*/sales_order/massHold'),
133
+ ));
134
+ }
135
+
136
+ if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/unhold')) {
137
+ $this->getMassactionBlock()->addItem('unhold_order', array(
138
+ 'label'=> Mage::helper('sales')->__('Unhold'),
139
+ 'url' => $this->getUrl('*/sales_order/massUnhold'),
140
+ ));
141
+ }
142
+
143
+ $this->getMassactionBlock()->addItem('pdfinvoices_order', array(
144
+ 'label'=> Mage::helper('sales')->__('Print Invoices'),
145
+ 'url' => $this->getUrl('*/sales_order/pdfinvoices'),
146
+ ));
147
+
148
+ $this->getMassactionBlock()->addItem('pdfshipments_order', array(
149
+ 'label'=> Mage::helper('sales')->__('Print Packingslips'),
150
+ 'url' => $this->getUrl('*/sales_order/pdfshipments'),
151
+ ));
152
+
153
+ $this->getMassactionBlock()->addItem('pdfcreditmemos_order', array(
154
+ 'label'=> Mage::helper('sales')->__('Print Credit Memos'),
155
+ 'url' => $this->getUrl('*/sales_order/pdfcreditmemos'),
156
+ ));
157
+
158
+ $this->getMassactionBlock()->addItem('pdfdocs_order', array(
159
+ 'label'=> Mage::helper('sales')->__('Print All'),
160
+ 'url' => $this->getUrl('*/sales_order/pdfdocs'),
161
+ ));
162
+
163
+ $this->getMassactionBlock()->addItem('print_shipping_label', array(
164
+ 'label'=> Mage::helper('sales')->__('Print Shipping Labels'),
165
+ 'url' => $this->getUrl('*/sales_order_shipment/massPrintShippingLabel'),
166
+ ));
167
+
168
+ $this->getMassactionBlock()->addItem('delete_order', array(
169
+ 'label'=> Mage::helper('sales')->__('Delete Order'),
170
+ 'url' => $this->getUrl('deleteorder/adminhtml_deleteorder/massDelete'),
171
+ 'confirm' => Mage::helper('sales')->__('Are you sure you want to delete order?')
172
+ ));
173
+
174
+ return $this;
175
+ }
176
+ public function getRowUrl($row)
177
+ {
178
+ if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
179
+ return $this->getUrl('*/sales_order/view', array('order_id' => $row->getId()));
180
+ }
181
+ return false;
182
+ }
183
+
184
+ public function getGridUrl()
185
+ {
186
+ return $this->getUrl('*/*/grid', array('_current'=>true));
187
+ }
188
+
189
+ }
190
+ ?>
app/code/community/SiteClue/Deleteorder/Block/Adminhtml/Sales/Order/Render/Delete.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SiteClue
4
+ * @category SiteClue
5
+ * @package SiteClue_Deleteorder
6
+ * @copyright Copyright (c) 2015-2016 SiteClue. (http://www.siteclue.com)
7
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
8
+ */
9
+
10
+ class SiteClue_Deleteorder_Block_Adminhtml_Sales_Order_Render_Delete extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
11
+ {
12
+ public function render(Varien_Object $row)
13
+ {
14
+ $getData = $row->getData();
15
+ $message = Mage::helper('sales')->__('Are you sure you want to delete this order?');
16
+ $orderID = $getData['entity_id'];
17
+ $view = $this->getUrl('*/sales_order/view',array('order_id' => $orderID));
18
+ $delete = $this->getUrl('deleteorder/adminhtml_deleteorder/delete',array('order_id' => $orderID));
19
+ $link = '<a href="'.$view.'">View</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="#" onclick="deleteConfirm(\''.$message.'\', \'' . $delete . '\')">Delete</a>';
20
+ return $link;
21
+ }
22
+
23
+
24
+ }
25
+
26
+ ?>
app/code/community/SiteClue/Deleteorder/Block/Adminhtml/Sales/Order/View.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SiteClue
4
+ * @category SiteClue
5
+ * @package SiteClue_Deleteorder
6
+ * @copyright Copyright (c) 2015-2016 SiteClue. (http://www.siteclue.com)
7
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
8
+ */
9
+
10
+ class SiteClue_Deleteorder_Block_Adminhtml_Sales_Order_View extends Mage_Adminhtml_Block_Sales_Order_View
11
+ {
12
+ public function __construct() {
13
+
14
+ parent::__construct();
15
+ $message = Mage::helper('sales')->__('Are you sure you want to delete this order?');
16
+ $this->_addButton('button_id', array(
17
+ 'label' => Mage::helper('Sales')->__('Delete Order'),
18
+ 'onclick' => 'deleteConfirm(\''.$message.'\', \'' . $this->getDeleteUrl() . '\')',
19
+ 'class' => 'go'
20
+ ), 0, 100, 'header', 'header');
21
+ }
22
+
23
+ public function getDeleteUrl()
24
+ {
25
+ return $this->getUrl('deleteorder/adminhtml_deleteorder/delete', array('_current'=>true));
26
+ }
27
+ }
28
+ ?>
app/code/community/SiteClue/Deleteorder/Helper/Data.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SiteClue
4
+ * @category SiteClue
5
+ * @package SiteClue_Deleteorder
6
+ * @copyright Copyright (c) 2015-2016 SiteClue. (http://www.siteclue.com)
7
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
8
+ */
9
+
10
+ class SiteClue_Deleteorder_Helper_Data extends Mage_Core_Helper_Abstract
11
+ {
12
+
13
+ }
app/code/community/SiteClue/Deleteorder/controllers/Adminhtml/DeleteorderController.php ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SiteClue
4
+ * @category SiteClue
5
+ * @package SiteClue_Deleteorder
6
+ * @copyright Copyright (c) 2015-2016 SiteClue. (http://www.siteclue.com)
7
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
8
+ */
9
+ class SiteClue_Deleteorder_Adminhtml_DeleteorderController extends Mage_Adminhtml_Controller_Action
10
+ {
11
+
12
+ protected function _initOrder()
13
+ {
14
+ $id = $this->getRequest()->getParam('order_id');
15
+ $order = Mage::getModel('sales/order')->load($id);
16
+
17
+ if (!$order->getId()) {
18
+ $this->_getSession()->addError($this->__('This order no longer exists.'));
19
+ $this->_redirect('*/*/');
20
+ $this->setFlag('', self::FLAG_NO_DISPATCH, true);
21
+ return false;
22
+ }
23
+ Mage::register('sales_order', $order);
24
+ Mage::register('current_order', $order);
25
+ return $order;
26
+ }
27
+ public function deleteAction() {
28
+ if($order = $this->_initOrder()) {
29
+ try {
30
+ $order->delete();
31
+ if($this->_deleteOrder($this->getRequest()->getParam('order_id'))){
32
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Order was successfully deleted'));
33
+ $this->_redirectUrl(Mage::helper('adminhtml')->getUrl('adminhtml/sales_order/index'));
34
+ }
35
+ } catch (Exception $e) {
36
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
37
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('order_ids')));
38
+ }
39
+ }
40
+ $this->_redirectUrl(Mage::helper('adminhtml')->getUrl('adminhtml/sales_order/index'));
41
+ }
42
+ public function massDeleteAction() {
43
+ $orderIds = $this->getRequest()->getParam('order_ids');
44
+ if(!is_array($orderIds)) {
45
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
46
+ } else {
47
+ try {
48
+ foreach ($orderIds as $orderId) {
49
+ Mage::getModel('sales/order')->load($orderId)->delete()->unsetAll();
50
+ $this->_deleteOrder($orderId);
51
+ }
52
+ Mage::getSingleton('adminhtml/session')->addSuccess(
53
+ Mage::helper('adminhtml')->__(
54
+ 'Total of %d record(s) were successfully deleted', count($orderIds)
55
+ )
56
+ );
57
+ } catch (Exception $e) {
58
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
59
+ }
60
+ }
61
+ $this->_redirectUrl(Mage::helper('adminhtml')->getUrl('adminhtml/sales_order/index'));
62
+ }
63
+
64
+ public function _deleteOrder($order_id){
65
+
66
+ $resource = Mage::getSingleton('core/resource');
67
+ $read = $resource->getConnection('core_read');
68
+
69
+ $order_tb = $resource->getTableName('sales_flat_order_grid');
70
+ $invoice_tb = $resource->getTableName('sales_flat_invoice_grid');
71
+ $shipment_tb = $resource->getTableName('sales_flat_shipment_grid');
72
+ $creditmemo_tb = $resource->getTableName('sales_flat_creditmemo_grid');
73
+
74
+ $sql = "DELETE FROM " . $order_tb . " WHERE entity_id = " . $order_id . ";";
75
+ $read->query($sql);
76
+ $sql = "DELETE FROM " . $invoice_tb . " WHERE order_id = " . $order_id . ";";
77
+ $read->query($sql);
78
+ $sql = "DELETE FROM " . $shipment_tb . " WHERE order_id = " . $order_id . ";";
79
+ $read->query($sql);
80
+ $sql = "DELETE FROM " . $creditmemo_tb . " WHERE order_id = " . $order_id . ";";
81
+ $read->query($sql);
82
+
83
+ return true;
84
+ }
85
+
86
+ }
app/code/community/SiteClue/Deleteorder/etc/config.xml ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <SiteClue_Deleteorder>
5
+ <version>1.0.0</version>
6
+ </SiteClue_Deleteorder>
7
+ </modules>
8
+ <admin>
9
+ <routers>
10
+ <deleteorder>
11
+ <use>admin</use>
12
+ <args>
13
+ <module>SiteClue_Deleteorder</module>
14
+ <frontName>deleteorder</frontName>
15
+ </args>
16
+ </deleteorder>
17
+ </routers>
18
+ </admin>
19
+ <adminhtml>
20
+ <acl>
21
+ <resources>
22
+ <all>
23
+ <title>Allow Everything</title>
24
+ </all>
25
+ <admin>
26
+ <children>
27
+ <SiteClue_Deleteorder>
28
+ <title>Deleteorder Module</title>
29
+ <sort_order>10</sort_order>
30
+ </SiteClue_Deleteorder>
31
+ </children>
32
+ </admin>
33
+ </resources>
34
+ </acl>
35
+ <layout>
36
+ <updates>
37
+ <deleteorder>
38
+ <file>deleteorder.xml</file>
39
+ </deleteorder>
40
+ </updates>
41
+ </layout>
42
+ </adminhtml>
43
+ <global>
44
+ <blocks>
45
+ <adminhtml>
46
+ <rewrite>
47
+ <sales_order_grid>SiteClue_Deleteorder_Block_Adminhtml_Sales_Order_Grid</sales_order_grid>
48
+ </rewrite>
49
+ <rewrite>
50
+ <sales_order_view>SiteClue_Deleteorder_Block_Adminhtml_Sales_Order_View</sales_order_view>
51
+ </rewrite>
52
+ </adminhtml>
53
+ <deleteorder>
54
+ <class>SiteClue_Deleteorder_Block</class>
55
+ </deleteorder>
56
+ </blocks>
57
+ <helpers>
58
+ <deleteorder>
59
+ <class>SiteClue_Deleteorder_Helper</class>
60
+ </deleteorder>
61
+ </helpers>
62
+ </global>
63
+ </config>
app/etc/modules/SiteClue_Deleteorder.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <SiteClue_Deleteorder>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </SiteClue_Deleteorder>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>SiteClue_Delete_Orders</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license>Academic Free License (AFL)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Simple tool for deleting Magento order extension. Single order delete and mass order delete features.</summary>
10
+ <description>Magento default does not allow to delete order and related documents like invoices, credit memos, shipments.You can only mark it to cancelled but you can't delete it. Delete Order by SiteClue help you to do that simply just simple clicks. Let's try&#xD;
11
+ &#xD;
12
+ Features:&#xD;
13
+ &#xD;
14
+ 1. Delete order with any status&#xD;
15
+ 2. Mass order delete&#xD;
16
+ 3. Delete all related documents like: invoice, credit memo, shipment&#xD;
17
+ 4. Easy Installation&#xD;
18
+ 5. Compatibility With Magento Community Editions.&#xD;
19
+ </description>
20
+ <notes>Simple tool for deleting Magento order extension. Single order delete and mass order delete features.</notes>
21
+ <authors><author><name>SiteClue</name><user>SiteClue</user><email>siteclue@gmail.com</email></author></authors>
22
+ <date>2015-01-13</date>
23
+ <time>21:05:22</time>
24
+ <contents><target name="magecommunity"><dir name="SiteClue"><dir name="Deleteorder"><dir name="Block"><dir name="Adminhtml"><dir name="Sales"><dir name="Order"><file name="Grid.php" hash="d435cfff61997d878d4855aaf8441ead"/><dir name="Render"><file name="Delete.php" hash="7935cbc2029959d0670481a5f8ff417d"/></dir><file name="View.php" hash="6422429fdac2465d68f94414f7340a2d"/></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="823fe4079664ed1854b8fd246aa8e9fb"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="DeleteorderController.php" hash="d122052f7bd65086ced94573b7565fba"/></dir></dir><dir name="etc"><file name="config.xml" hash="09aab3693ec5f703657b0680db11d88f"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="SiteClue_Deleteorder.xml" hash="d0f97a4678aa8420ff52cb49d178e47c"/></dir></target></contents>
25
+ <compatible/>
26
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.6.0.0</min><max>1.9.1.0</max></package></required></dependencies>
27
+ </package>