Brainvire_Orders_Delete - Version 1.0.2

Version Notes

Brainvire Order Delete Extension Release V1.0.2

Download this release

Release Info

Developer Magento Core Team
Extension Brainvire_Orders_Delete
Version 1.0.2
Comparing to
See all releases


Code changes from version 1.0.1 to 1.0.2

app/code/community/Brainvire/DeleteOrder/Block/Adminhtml/Sales/Order/Grid.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Brainvire_DeleteOrder_Block_Adminhtml_Sales_Order_Grid extends Mage_Adminhtml_Block_Sales_Order_Grid
3
+ {
4
+ protected function _prepareMassaction()
5
+ {
6
+ parent::_prepareMassaction();
7
+
8
+ $this->getMassactionBlock()->addItem('delete_order', array(
9
+ 'label'=> Mage::helper('sales')->__('Delete order'),
10
+ 'url' => $this->getUrl('*/sales_order/deleteorder'),
11
+ ));
12
+ return $this;
13
+ }
14
+ }
app/code/community/Brainvire/DeleteOrder/controllers/Adminhtml/Sales/OrderController.php ADDED
@@ -0,0 +1,199 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require_once 'Mage/Adminhtml/controllers/Sales/OrderController.php';
3
+ class Brainvire_DeleteOrder_Adminhtml_Sales_OrderController extends Mage_Adminhtml_Sales_OrderController
4
+ {
5
+ public function deleteorderAction()
6
+ {
7
+
8
+ $orderIds = $this->getRequest()->getPost('order_ids');
9
+ $flag = false;
10
+ $write = Mage::getSingleton('core/resource')->getConnection('core_write');
11
+ $query="show tables";
12
+ $delorder_table=$write->fetchCol($query);
13
+
14
+ $table_sales_flat_order = Mage::getSingleton('core/resource')->getTableName('sales_flat_order');
15
+ $table_sales_flat_creditmemo_comment= Mage::getSingleton('core/resource')->getTableName('sales_flat_creditmemo_comment');
16
+ $table_sales_flat_creditmemo_item= Mage::getSingleton('core/resource')->getTableName('sales_flat_creditmemo_item');
17
+ $table_sales_flat_creditmemo= Mage::getSingleton('core/resource')->getTableName('sales_flat_creditmemo');
18
+ $table_sales_flat_creditmemo_grid= Mage::getSingleton('core/resource')->getTableName('sales_flat_creditmemo_grid');
19
+ $table_sales_flat_invoice_comment= Mage::getSingleton('core/resource')->getTableName('sales_flat_invoice_comment');
20
+ $table_sales_flat_invoice_item= Mage::getSingleton('core/resource')->getTableName('sales_flat_invoice_item');
21
+ $table_sales_flat_invoice= Mage::getSingleton('core/resource')->getTableName('sales_flat_invoice');
22
+ $table_sales_flat_invoice_grid= Mage::getSingleton('core/resource')->getTableName('sales_flat_invoice_grid');
23
+ $table_sales_flat_quote_address_item= Mage::getSingleton('core/resource')->getTableName('sales_flat_quote_address_item');
24
+ $table_sales_flat_quote_item_option= Mage::getSingleton('core/resource')->getTableName('sales_flat_quote_item_option');
25
+ $table_sales_flat_quote= Mage::getSingleton('core/resource')->getTableName('sales_flat_quote');
26
+ $table_sales_flat_quote_address= Mage::getSingleton('core/resource')->getTableName('sales_flat_quote_address');
27
+ $table_sales_flat_quote_item= Mage::getSingleton('core/resource')->getTableName('sales_flat_quote_item');
28
+ $table_sales_flat_quote_payment= Mage::getSingleton('core/resource')->getTableName('sales_flat_quote_payment');
29
+ $table_sales_flat_shipment_comment= Mage::getSingleton('core/resource')->getTableName('sales_flat_shipment_comment');
30
+ $table_sales_flat_shipment_item= Mage::getSingleton('core/resource')->getTableName('sales_flat_shipment_item');
31
+ $table_sales_flat_shipment_track= Mage::getSingleton('core/resource')->getTableName('sales_flat_shipment_track');
32
+ $table_sales_flat_shipment= Mage::getSingleton('core/resource')->getTableName('sales_flat_shipment');
33
+ $table_sales_flat_shipment_grid= Mage::getSingleton('core/resource')->getTableName('sales_flat_shipment_grid');
34
+ $table_sales_flat_order_address= Mage::getSingleton('core/resource')->getTableName('sales_flat_order_address');
35
+ $table_sales_flat_order_item= Mage::getSingleton('core/resource')->getTableName('sales_flat_order_item');
36
+ $table_sales_flat_order_payment= Mage::getSingleton('core/resource')->getTableName('sales_flat_order_payment');
37
+ $table_sales_flat_order_status_history= Mage::getSingleton('core/resource')->getTableName('sales_flat_order_status_history');
38
+ $table_sales_flat_order_grid= Mage::getSingleton('core/resource')->getTableName('sales_flat_order_grid');
39
+ $table_log_quote= Mage::getSingleton('core/resource')->getTableName('log_quote');
40
+ $quoteId='';
41
+ if (!empty($orderIds)) {
42
+ foreach ($orderIds as $orderId) {
43
+ $query=null;
44
+ $order = Mage::getModel('sales/order')->load($orderId);
45
+ if($order->increment_id){
46
+ /*$query="show tables like 'sales_flat_order'";
47
+ $rs=$write->fetchAll($query);*/
48
+ $incId=$order->increment_id;
49
+ if(in_array($table_sales_flat_order,$delorder_table)){
50
+ $query='SELECT entity_id FROM '.$table_sales_flat_order.' WHERE increment_id="'.mysql_escape_string($incId).'"';
51
+
52
+ $rs=$write->fetchAll($query);
53
+
54
+ $query='SELECT quote_id FROM '.$table_sales_flat_order.' WHERE entity_id="'.mysql_escape_string($orderId).'"';
55
+ $rs1=$write->fetchAll($query);
56
+ $quoteId=$rs1[0]['quote_id'];
57
+ }
58
+
59
+ $query='SET FOREIGN_KEY_CHECKS=1';
60
+ $rs3=$write->query($query);
61
+ if(in_array($table_sales_flat_creditmemo_comment,$delorder_table)){
62
+
63
+ $write->query("DELETE FROM ".$table_sales_flat_creditmemo_comment." WHERE parent_id IN (SELECT entity_id FROM ".$table_sales_flat_creditmemo." WHERE order_id='".mysql_escape_string($orderId)."')");
64
+ }
65
+
66
+
67
+
68
+ if(in_array('sales_flat_creditmemo_item',$delorder_table)){
69
+ $write->query("DELETE FROM ".$table_sales_flat_creditmemo_item." WHERE parent_id IN (SELECT entity_id FROM ".$table_sales_flat_creditmemo." WHERE order_id='".mysql_escape_string($orderId)."')");
70
+ }
71
+
72
+
73
+ if(in_array($table_sales_flat_creditmemo,$delorder_table)){
74
+ $write->query("DELETE FROM ".$table_sales_flat_creditmemo." WHERE order_id='".mysql_escape_string($orderId)."'");
75
+ }
76
+
77
+
78
+
79
+ if(in_array($table_sales_flat_creditmemo_grid,$delorder_table)){
80
+ $write->query("DELETE FROM ".$table_sales_flat_creditmemo_grid." WHERE order_id='".mysql_escape_string($orderId)."'");
81
+ }
82
+
83
+
84
+ if(in_array($table_sales_flat_invoice_comment,$delorder_table)){
85
+
86
+ $write->query("DELETE FROM ".$table_sales_flat_invoice_comment." WHERE parent_id IN (SELECT entity_id FROM ".$table_sales_flat_invoice." WHERE order_id='".mysql_escape_string($orderId)."')");
87
+ }
88
+
89
+ if(in_array($table_sales_flat_invoice_item,$delorder_table)){
90
+
91
+ $write->query("DELETE FROM ".$table_sales_flat_invoice_item." WHERE parent_id IN (SELECT entity_id FROM ".$table_sales_flat_invoice." WHERE order_id='".mysql_escape_string($orderId)."')");
92
+ }
93
+
94
+
95
+ if(in_array($table_sales_flat_invoice,$delorder_table)){
96
+
97
+ $write->query("DELETE FROM ".$table_sales_flat_invoice." WHERE order_id='".mysql_escape_string($orderId)."'");
98
+ }
99
+
100
+ if(in_array($table_sales_flat_invoice_grid,$delorder_table)){
101
+
102
+ $write->query("DELETE FROM ".$table_sales_flat_invoice_grid." WHERE order_id='".mysql_escape_string($orderId)."'");
103
+ }
104
+
105
+ if($quoteId){
106
+ if(in_array($table_sales_flat_quote_address_item,$delorder_table)){
107
+ $write->query("DELETE FROM ".$table_sales_flat_quote_address_item." WHERE parent_item_id IN (SELECT address_id FROM ".$table_sales_flat_quote_address." WHERE quote_id=".$quoteId.")");
108
+ }
109
+
110
+ $table_sales_flat_quote_shipping_rate= Mage::getSingleton('core/resource')->getTableName('sales_flat_quote_shipping_rate');
111
+ if(in_array($table_sales_flat_quote_shipping_rate,$delorder_table)){
112
+ $write->query("DELETE FROM ".$table_sales_flat_quote_shipping_rate." WHERE address_id IN (SELECT address_id FROM ".$table_sales_flat_quote_address." WHERE quote_id=".$quoteId.")");
113
+ }
114
+
115
+ if(in_array($table_sales_flat_quote_item_option,$delorder_table)){
116
+ $write->query("DELETE FROM ".$table_sales_flat_quote_item_option." WHERE item_id IN (SELECT item_id FROM ".$table_sales_flat_quote_item." WHERE quote_id=".$quoteId.")");
117
+ }
118
+
119
+
120
+ if(in_array($table_sales_flat_quote,$delorder_table)){
121
+ $write->query("DELETE FROM ".$table_sales_flat_quote." WHERE entity_id=".$quoteId);
122
+ }
123
+
124
+ if(in_array($table_sales_flat_quote_address,$delorder_table)){
125
+ $write->query("DELETE FROM ".$table_sales_flat_quote_address." WHERE quote_id=".$quoteId);
126
+ }
127
+
128
+ if(in_array($table_sales_flat_quote_item,$delorder_table)){
129
+ $write->query("DELETE FROM ".$table_sales_flat_quote_item." WHERE quote_id=".$quoteId);
130
+ }
131
+
132
+ if(in_array('sales_flat_quote_payment',$delorder_table)){
133
+ $write->query("DELETE FROM ".$table_sales_flat_quote_payment." WHERE quote_id=".$quoteId);
134
+ }
135
+
136
+ }
137
+
138
+
139
+ if(in_array($table_sales_flat_shipment_comment,$delorder_table)){
140
+ $write->query("DELETE FROM ".$table_sales_flat_shipment_comment." WHERE parent_id IN (SELECT entity_id FROM ".$table_sales_flat_shipment." WHERE order_id='".mysql_escape_string($orderId)."')");
141
+ }
142
+
143
+ if(in_array($table_sales_flat_shipment_item,$delorder_table)){
144
+ $write->query("DELETE FROM ".$table_sales_flat_shipment_item." WHERE parent_id IN (SELECT entity_id FROM ".$table_sales_flat_shipment." WHERE order_id='".mysql_escape_string($orderId)."')");
145
+ }
146
+
147
+
148
+ if(in_array($table_sales_flat_shipment_track,$delorder_table)){
149
+ $write->query("DELETE FROM ".$table_sales_flat_shipment_track." WHERE order_id IN (SELECT entity_id FROM ".$table_sales_flat_shipment." WHERE order_id='".mysql_escape_string($orderId)."')");
150
+ }
151
+
152
+
153
+ if(in_array($table_sales_flat_shipment,$delorder_table)){
154
+
155
+ $write->query("DELETE FROM ".$table_sales_flat_shipment." WHERE order_id='".mysql_escape_string($orderId)."'");
156
+ }
157
+
158
+
159
+ if(in_array($table_sales_flat_shipment_grid,$delorder_table)){
160
+ $write->query("DELETE FROM ".$table_sales_flat_shipment_grid." WHERE order_id='".mysql_escape_string($orderId)."'");
161
+ }
162
+
163
+ if(in_array($table_sales_flat_order,$delorder_table)){
164
+ $write->query("DELETE FROM ".$table_sales_flat_order." WHERE entity_id='".mysql_escape_string($orderId)."'");
165
+ }
166
+
167
+ if(in_array($table_sales_flat_order_address,$delorder_table)){
168
+ $write->query("DELETE FROM ".$table_sales_flat_order_address." WHERE parent_id='".mysql_escape_string($orderId)."'");
169
+ }
170
+
171
+ if(in_array($table_sales_flat_order_item,$delorder_table)){
172
+ $write->query("DELETE FROM ".$table_sales_flat_order_item." WHERE order_id='".mysql_escape_string($orderId)."'");
173
+ }
174
+ if(in_array($table_sales_flat_order_payment,$delorder_table)){
175
+ $write->query("DELETE FROM ".$table_sales_flat_order_payment." WHERE parent_id='".mysql_escape_string($orderId)."'");
176
+ }
177
+ if(in_array($table_sales_flat_order_status_history,$delorder_table)){
178
+ $write->query("DELETE FROM ".$table_sales_flat_order_status_history." WHERE parent_id='".mysql_escape_string($orderId)."'");
179
+ }
180
+ if($incId&&in_array($table_sales_flat_order_grid,$delorder_table)){
181
+ $write->query("DELETE FROM ".$table_sales_flat_order_grid." WHERE increment_id='".mysql_escape_string($incId)."'");
182
+
183
+ }
184
+
185
+ $query="show tables like '%".$table_log_quote."'";
186
+ $delorder_table_l=$write->fetchCol($query);
187
+ if($quoteId&&$delorder_table_l){
188
+ $write->query("DELETE FROM ".$table_log_quote." WHERE quote_id=".$quoteId);
189
+ }
190
+ $write->query("SET FOREIGN_KEY_CHECKS=1");
191
+ }
192
+ }
193
+ $this->_getSession()->addSuccess($this->__('Order Deleted.'));
194
+ }else{
195
+ $this->_getSession()->addError($this->__('Order error.'));
196
+ }
197
+ $this->_redirect('*/*/');
198
+ }
199
+ }
app/code/community/Brainvire/DeleteOrder/etc/config.xml ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Brainvire_DeleteOrder>
5
+ <version>0.1.0</version>
6
+ </Brainvire_DeleteOrder>
7
+ </modules>
8
+ <admin>
9
+ <routers>
10
+ <deleteorder>
11
+ <use>admin</use>
12
+ <args>
13
+ <module>Brainvire_DeleteOrder</module>
14
+ <frontName>deleteorder</frontName>
15
+ </args>
16
+ </deleteorder>
17
+ </routers>
18
+ </admin>
19
+ <global>
20
+ <rewrite>
21
+ <brainvire_deleteorder_adminhtml_sales_order>
22
+ <from><![CDATA[#/admin/sales_order/#]]></from>
23
+ <to>/deleteorder/adminhtml_sales_order/</to>
24
+ </brainvire_deleteorder_adminhtml_sales_order>
25
+ </rewrite>
26
+ <blocks>
27
+ <adminhtml>
28
+ <rewrite>
29
+ <sales_order_grid>Brainvire_DeleteOrder_Block_Adminhtml_Sales_Order_Grid</sales_order_grid>
30
+ </rewrite>
31
+ </adminhtml>
32
+ </blocks>
33
+ </global>
34
+ </config>
app/etc/modules/Brainvire_DeleteOrder.xml CHANGED
@@ -1,12 +1,9 @@
1
- <?xml version="1.0"?>
2
- <config>
3
- <modules>
4
- <Brainvire_DeleteOrder>
5
- <active>true</active>
6
- <codePool>community</codePool>
7
- <depends>
8
- <Brainvire_OrderComment/>
9
- </depends>
10
- </Brainvire_DeleteOrder>
11
- </modules>
12
  </config>
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Brainvire_DeleteOrder>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Brainvire_DeleteOrder>
8
+ </modules>
 
 
 
9
  </config>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Brainvire_Orders_Delete</name>
4
- <version>1.0.1</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
7
  <channel>community</channel>
@@ -31,11 +31,11 @@
31
  &lt;ul&gt;&#xD;
32
  &lt;li&gt;Allow to delete selected mutliple orders from magento admin panel&lt;/li&gt;&#xD;
33
  &lt;/ul&gt;</description>
34
- <notes>Brainvire Order Delete Extension Release V1.0.1</notes>
35
- <authors><author><name>Brainvire Infotech Private Limited</name><user>brainvire</user><email>magento@brainvire.com</email></author></authors>
36
- <date>2013-01-25</date>
37
- <time>15:57:52</time>
38
- <contents><target name="mageetc"><dir name="modules"><file name="Brainvire_DeleteOrder.xml" hash=""/></dir></target></contents>
39
  <compatible/>
40
- <dependencies><required><php><min>5.1.0</min><max>100.0.0</max></php></required></dependencies>
41
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Brainvire_Orders_Delete</name>
4
+ <version>1.0.2</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
7
  <channel>community</channel>
31
  &lt;ul&gt;&#xD;
32
  &lt;li&gt;Allow to delete selected mutliple orders from magento admin panel&lt;/li&gt;&#xD;
33
  &lt;/ul&gt;</description>
34
+ <notes>Brainvire Order Delete Extension Release V1.0.2</notes>
35
+ <authors><author><name>Brainvire Infotech Private Limited</name><user>auto-converted</user><email>magento@brainvire.com</email></author></authors>
36
+ <date>2013-01-28</date>
37
+ <time>11:21:24</time>
38
+ <contents><target name="magecommunity"><dir name="Brainvire"><dir name="DeleteOrder"><dir name="Block"><dir name="Adminhtml"><dir name="Sales"><dir name="Order"><file name="Grid.php" hash="1ffe75efc48dbcc8b855612fe5536b83"/></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Sales"><file name="OrderController.php" hash="d7baf903d9f66cd4221c85d2e984e647"/></dir></dir></dir><dir name="etc"><file name="config.xml" hash="ef4d5c12b3d4c900d1fbf3faca62d489"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Brainvire_DeleteOrder.xml" hash="fa297bd7a42e9057d4370e9957bf271f"/></dir></target></contents>
39
  <compatible/>
40
+ <dependencies/>
41
  </package>