Wyomind_OrdersEraser - Version 3.1.0

Version Notes

none

Download this release

Release Info

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


Code changes from version 3.0.1 to 3.1.0

app/code/community/Wyomind/Orderseraser/Block/Order/Grid.php CHANGED
File without changes
app/code/community/Wyomind/Orderseraser/Model/Orderseraser.php CHANGED
@@ -1 +1,50 @@
1
- <?php
2
  public function _erase($orderId) {
3
  $resource = Mage::getSingleton('core/resource');
4
  $delete = $resource->getConnection('core_read');
5
  $tableSo = $resource->getTableName('sales_order');
6
  $tableSoe = $resource->getTableName('sales_order_entity');
7
  $tableSoei = $resource->getTableName('sales_order_entity_int');
8
  $tableEa = $resource->getTableName('eav_attribute');
9
  $tableSfoi = $resource->getTableName('sales_flat_order_item');
10
  $sql = "DELETE FROM " . $tableSo . " WHERE entity_id = " . $orderId . ";";
11
  $delete->query($sql);
12
  $sql = "DELETE FROM " . $tableSoe . " WHERE parent_id = " . $orderId . ";";
13
  $delete->query($sql);
14
  $sql = "DELETE s FROM " . $tableSoe . " s
15
  $delete->query($sql);
16
  $sql = "DELETE FROM " . $tableSfoi . " WHERE order_id=" . $orderId . ";";
17
  $delete->query($sql);
18
  return true;
19
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  public function _erase($orderId) {
2
  $resource = Mage::getSingleton('core/resource');
3
  $delete = $resource->getConnection('core_read');
4
  $tableSo = $resource->getTableName('sales_order');
5
  $tableSoe = $resource->getTableName('sales_order_entity');
6
  $tableSoei = $resource->getTableName('sales_order_entity_int');
7
  $tableEa = $resource->getTableName('eav_attribute');
8
  $tableSfoi = $resource->getTableName('sales_flat_order_item');
9
  $sql = "DELETE FROM " . $tableSo . " WHERE entity_id = " . $orderId . ";";
10
  $delete->query($sql);
11
  $sql = "DELETE FROM " . $tableSoe . " WHERE parent_id = " . $orderId . ";";
12
  $delete->query($sql);
13
  $sql = "DELETE s FROM " . $tableSoe . " s
14
  $delete->query($sql);
15
  $sql = "DELETE FROM " . $tableSfoi . " WHERE order_id=" . $orderId . ";";
16
  $delete->query($sql);
17
  return true;
18
  }
19
+ <?php
20
+
21
+
22
+ class Wyomind_Orderseraser_Model_Orderseraser extends Varien_Object {
23
+
24
+ public function _erase1($orderId) {
25
+
26
+ $resource = Mage::getSingleton('core/resource');
27
+ $delete = $resource->getConnection('core_read');
28
+ $tableSo = $resource->getTableName('sales_order');
29
+ $tableSoe = $resource->getTableName('sales_order_entity');
30
+ $tableSoei = $resource->getTableName('sales_order_entity_int');
31
+ $tableEa = $resource->getTableName('eav_attribute');
32
+ $tableSfoi = $resource->getTableName('sales_flat_order_item');
33
+
34
+ $sql = "DELETE FROM " . $tableSo . " WHERE entity_id = " . $orderId . ";";
35
+ $delete->query($sql);
36
+ $sql = "DELETE FROM " . $tableSoe . " WHERE parent_id = " . $orderId . ";";
37
+ $delete->query($sql);
38
+ $sql = "DELETE s FROM " . $tableSoe . " s
39
+ JOIN " . $tableSoei . " si on s.entity_id = si.entity_id
40
+ JOIN " . $tableEa . " a on si.attribute_id = a.attribute_id
41
+ WHERE a.attribute_code = 'order_id'
42
+ AND si.value = " . $orderId . ";";
43
+ $delete->query($sql);
44
+ $sql = "DELETE FROM " . $tableSfoi . " WHERE order_id=" . $orderId . ";";
45
+ $delete->query($sql);
46
+
47
+ return true;
48
+ }
49
+ public function _erase2($orderId) {
50
+
51
+ $resource = Mage::getSingleton('core/resource');
52
+ $delete = $resource->getConnection('core_read');
53
+ $tableSfo = $resource->getTableName('sales_flat_order');
54
+ $tableSfog = $resource->getTableName('sales_flat_order_grid');
55
+
56
+
57
+ $sql = "DELETE FROM " . $tableSfo . " WHERE entity_id = " . $orderId . ";";
58
+
59
+ $delete->query($sql);
60
+ $sql = "DELETE FROM " . $tableSfog . " WHERE entity_id = " . $orderId . ";";
61
+ $delete->query($sql);
62
+
63
+
64
+ return true;
65
+ }
66
+
67
+ }
68
+
app/code/community/Wyomind/Orderseraser/controllers/Adminhtml/OrderseraserController.php CHANGED
@@ -1 +1,57 @@
1
- <?php
2
  public function getVersion() {
3
  return substr(Mage::getVersion(), 0, 3);
4
  }
5
  protected function _initOrder() {
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
  if (!$this->getRequest()->getParam('eraser'))
11
  $this->_redirect('adminhtml/sales_order/');
12
  else
13
  $this->_redirect('orderseraser/adminhtml_orderseraser');
14
  $this->setFlag('', self::FLAG_NO_DISPATCH, true);
15
  return false;
16
  }
17
  Mage::register('sales_order', $order);
18
  Mage::register('current_order', $order);
19
  return $order;
20
  }
21
  public function massDeleteAction() {
22
  $orderIds = $this->getRequest()->getPost('order_ids', array());
23
  $countDeleteOrder = 0;
24
  foreach ($orderIds as $orderId) {
25
  if ($this->getVersion() <= 1.3 && Mage::getModel('orderseraser/orderseraser')->_erase($orderId))
26
  $countDeleteOrder++;
27
  elseif (Mage::getModel('sales/order')->load($orderId)->delete())
28
  $countDeleteOrder++;
29
  }
30
  if ($countDeleteOrder > 0) {
31
  $this->_getSession()->addSuccess($this->__('%s order(s) successfully deleted', $countDeleteOrder));
32
  } else {
33
  $this->_getSession()->addError($this->__('Unable to delete orders.'));
34
  }
35
  if (!$this->getRequest()->getParam('eraser'))
36
  $this->_redirect('adminhtml/sales_order/');
37
  else
38
  $this->_redirect('orderseraser/adminhtml_orderseraser');
39
  }
40
  public function deleteAction() {
41
  if ($order = $this->_initOrder()) {
42
  try {
43
  if ($this->getVersion() <= 1.3)
44
  Mage::getModel('orderseraser/orderseraser')->_erase($order->getId());
45
  else
46
  $order->delete();
47
  $this->_getSession()->addSuccess(
48
  $this->__('Order was successfully deleted.')
49
  );
50
  } catch (Mage_Core_Exception $e) {
51
  $this->_getSession()->addError($e->getMessage());
52
  } catch (Exception $e) {
53
  $this->_getSession()->addError($this->__('Unable to delete order.'));
54
  }
55
  if (!$this->getRequest()->getParam('eraser'))
56
  $this->_redirect('adminhtml/sales_order/');
57
  else
58
  $this->_redirect('orderseraser/adminhtml_orderseraser');
59
  }
60
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  public function getVersion() {
2
  return substr(Mage::getVersion(), 0, 3);
3
  }
4
  protected function _initOrder() {
5
  $id = $this->getRequest()->getParam('order_id');
6
  $order = Mage::getModel('sales/order')->load($id);
7
  if (!$order->getId()) {
8
  $this->_getSession()->addError($this->__('This order no longer exists.'));
9
  if (!$this->getRequest()->getParam('eraser'))
10
  $this->_redirect('adminhtml/sales_order/');
11
  else
12
  $this->_redirect('orderseraser/adminhtml_orderseraser');
13
  $this->setFlag('', self::FLAG_NO_DISPATCH, true);
14
  return false;
15
  }
16
  Mage::register('sales_order', $order);
17
  Mage::register('current_order', $order);
18
  return $order;
19
  }
20
  public function massDeleteAction() {
21
  $orderIds = $this->getRequest()->getPost('order_ids', array());
22
  $countDeleteOrder = 0;
23
  foreach ($orderIds as $orderId) {
24
  if ($this->getVersion() <= 1.3 && Mage::getModel('orderseraser/orderseraser')->_erase($orderId))
25
  $countDeleteOrder++;
26
  elseif (Mage::getModel('sales/order')->load($orderId)->delete())
27
  $countDeleteOrder++;
28
  }
29
  if ($countDeleteOrder > 0) {
30
  $this->_getSession()->addSuccess($this->__('%s order(s) successfully deleted', $countDeleteOrder));
31
  } else {
32
  $this->_getSession()->addError($this->__('Unable to delete orders.'));
33
  }
34
  if (!$this->getRequest()->getParam('eraser'))
35
  $this->_redirect('adminhtml/sales_order/');
36
  else
37
  $this->_redirect('orderseraser/adminhtml_orderseraser');
38
  }
39
  public function deleteAction() {
40
  if ($order = $this->_initOrder()) {
41
  try {
42
  if ($this->getVersion() <= 1.3)
43
  Mage::getModel('orderseraser/orderseraser')->_erase($order->getId());
44
  else
45
  $order->delete();
46
  $this->_getSession()->addSuccess(
47
  $this->__('Order was successfully deleted.')
48
  );
49
  } catch (Mage_Core_Exception $e) {
50
  $this->_getSession()->addError($e->getMessage());
51
  } catch (Exception $e) {
52
  $this->_getSession()->addError($this->__('Unable to delete order.'));
53
  }
54
  if (!$this->getRequest()->getParam('eraser'))
55
  $this->_redirect('adminhtml/sales_order/');
56
  else
57
  $this->_redirect('orderseraser/adminhtml_orderseraser');
58
  }
59
  }
60
+ <?php
61
+
62
+ class Wyomind_Orderseraser_Adminhtml_OrderseraserController extends Mage_Adminhtml_Controller_Action {
63
+
64
+ public function getVersion() {
65
+ return substr(Mage::getVersion(), 0, 3);
66
+ }
67
+
68
+
69
+
70
+ public function massDeleteAction() {
71
+
72
+ $orderIds = $this->getRequest()->getPost('order_ids', array());
73
+ $countDeleteOrder = 0;
74
+ foreach ($orderIds as $orderId) {
75
+ if ($this->getVersion() <= 1.3 && Mage::getModel('orderseraser/orderseraser')->_erase1($orderId))
76
+ $countDeleteOrder++;
77
+ elseif (Mage::getModel('orderseraser/orderseraser')->_erase2($orderId))
78
+ $countDeleteOrder++;
79
+ }
80
+ if ($countDeleteOrder > 0) {
81
+ $this->_getSession()->addSuccess($this->__('%s order(s) successfully deleted', $countDeleteOrder));
82
+ } else {
83
+ $this->_getSession()->addError($this->__('Unable to delete orders.'));
84
+ }
85
+
86
+ $this->_redirect('adminhtml/sales_order/');
87
+
88
+ }
89
+
90
+ public function deleteAction() {
91
+
92
+ if ($orderId = $this->getRequest()->getParam('order_id')) {
93
+
94
+ try {
95
+
96
+ if ($this->getVersion() <= 1.3)
97
+ Mage::getModel('orderseraser/orderseraser')->_erase1($orderId);
98
+ else
99
+
100
+ Mage::getModel('orderseraser/orderseraser')->_erase2($orderId);
101
+
102
+ $this->_getSession()->addSuccess(
103
+ $this->__('Order was successfully deleted.')
104
+ );
105
+ } catch (Mage_Core_Exception $e) {
106
+ $this->_getSession()->addError($e->getMessage());
107
+ } catch (Exception $e) {
108
+ $this->_getSession()->addError($this->__('Unable to delete order.'));
109
+ }
110
+
111
+ $this->_redirect('adminhtml/sales_order/');
112
+
113
+ }
114
+ }
115
+
116
+ }
app/code/community/Wyomind/Orderseraser/etc/config.xml CHANGED
@@ -1,94 +1,94 @@
1
- <?xml version="1.0"?>
2
-
3
-
4
- <config>
5
-
6
- <modules>
7
-
8
- <Wyomind_Orderseraser>
9
-
10
- <version>3.0.1</version>
11
-
12
- </Wyomind_Orderseraser>
13
-
14
- </modules>
15
-
16
- <admin>
17
- <routers>
18
- <orderseraser>
19
- <use>admin</use>
20
- <args>
21
- <module>Wyomind_Orderseraser</module>
22
- <frontName>orderseraser</frontName>
23
- </args>
24
- </orderseraser>
25
- </routers>
26
- </admin>
27
- <adminhtml>
28
- <acl>
29
- <resources>
30
- <all>
31
- <title>Allow Everything</title>
32
- </all>
33
- <admin>
34
- <children>
35
- <sales>
36
- <children>
37
- <order>
38
- <children>
39
- <actions>
40
- <children>
41
- <delete translate="title">
42
- <title>Delete (Orders Eraser)</title>
43
- </delete>
44
- </children>
45
- </actions>
46
- </children>
47
- </order>
48
- </children>
49
- </sales>
50
- </children>
51
- </admin>
52
- </resources>
53
- </acl>
54
-
55
- </adminhtml>
56
- <global>
57
-
58
- <models>
59
- <orderseraser>
60
- <class>Wyomind_Orderseraser_Model</class>
61
- </orderseraser>
62
- </models>
63
- <resources>
64
- <orderseraser_write>
65
- <connection>
66
- <use>core_write</use>
67
- </connection>
68
- </orderseraser_write>
69
- <orderseraser_read>
70
- <connection>
71
- <use>core_read</use>
72
- </connection>
73
- </orderseraser_read>
74
- </resources>
75
- <blocks>
76
- <adminhtml>
77
- <rewrite>
78
- <sales_order_grid>Wyomind_Orderseraser_Block_Order_Grid</sales_order_grid>
79
- </rewrite>
80
- </adminhtml>
81
- </blocks>
82
- <helpers>
83
- <orderseraser>
84
- <class>Wyomind_Orderseraser_Helper</class>
85
- </orderseraser>
86
- </helpers>
87
- </global>
88
- </config>
89
-
90
-
91
-
92
-
93
-
94
-
1
+ <?xml version="1.0"?>
2
+
3
+
4
+ <config>
5
+
6
+ <modules>
7
+
8
+ <Wyomind_Orderseraser>
9
+
10
+ <version>3.1.0</version>
11
+
12
+ </Wyomind_Orderseraser>
13
+
14
+ </modules>
15
+
16
+ <admin>
17
+ <routers>
18
+ <orderseraser>
19
+ <use>admin</use>
20
+ <args>
21
+ <module>Wyomind_Orderseraser</module>
22
+ <frontName>orderseraser</frontName>
23
+ </args>
24
+ </orderseraser>
25
+ </routers>
26
+ </admin>
27
+ <adminhtml>
28
+ <acl>
29
+ <resources>
30
+ <all>
31
+ <title>Allow Everything</title>
32
+ </all>
33
+ <admin>
34
+ <children>
35
+ <sales>
36
+ <children>
37
+ <order>
38
+ <children>
39
+ <actions>
40
+ <children>
41
+ <delete translate="title">
42
+ <title>Delete (Orders Eraser)</title>
43
+ </delete>
44
+ </children>
45
+ </actions>
46
+ </children>
47
+ </order>
48
+ </children>
49
+ </sales>
50
+ </children>
51
+ </admin>
52
+ </resources>
53
+ </acl>
54
+
55
+ </adminhtml>
56
+ <global>
57
+
58
+ <models>
59
+ <orderseraser>
60
+ <class>Wyomind_Orderseraser_Model</class>
61
+ </orderseraser>
62
+ </models>
63
+ <resources>
64
+ <orderseraser_write>
65
+ <connection>
66
+ <use>core_write</use>
67
+ </connection>
68
+ </orderseraser_write>
69
+ <orderseraser_read>
70
+ <connection>
71
+ <use>core_read</use>
72
+ </connection>
73
+ </orderseraser_read>
74
+ </resources>
75
+ <blocks>
76
+ <adminhtml>
77
+ <rewrite>
78
+ <sales_order_grid>Wyomind_Orderseraser_Block_Order_Grid</sales_order_grid>
79
+ </rewrite>
80
+ </adminhtml>
81
+ </blocks>
82
+ <helpers>
83
+ <orderseraser>
84
+ <class>Wyomind_Orderseraser_Helper</class>
85
+ </orderseraser>
86
+ </helpers>
87
+ </global>
88
+ </config>
89
+
90
+
91
+
92
+
93
+
94
+
app/etc/modules/Wyomind_Orderseraser.xml CHANGED
File without changes
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Wyomind_OrdersEraser</name>
4
- <version>3.0.1</version>
5
  <stability>stable</stability>
6
  <license>GPL</license>
7
  <channel>community</channel>
@@ -9,10 +9,10 @@
9
  <summary>Orders eraser allows to simply clean your sales database by deleting any useless orders and linked invoices and/or shipping in once.</summary>
10
  <description>Orders eraser allows to simply clean your sales database by deleting any useless orders and linked invoices and/or shipping in once.</description>
11
  <notes>none</notes>
12
- <authors><author><name>Wyomind</name><user>Pierre</user><email>contact@wyomind.com</email></author></authors>
13
  <date>2012-04-10</date>
14
- <time>10:05:24</time>
15
- <contents><target name="mageetc"><dir name="modules"><file name="Wyomind_Orderseraser.xml" hash="43aa1ed1daf4f94fee1dddde51b9160c"/></dir></target><target name="magecommunity"><dir name="Wyomind"><dir name="Orderseraser"><dir name="Block"><dir name="Order"><file name="Grid.php" hash="4005a0d98668faa75bb080abc27008ba"/></dir></dir><dir name="Model"><file name="Orderseraser.php" hash="ad10c5807fdd519809ce5b132cc25f52"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="OrderseraserController.php" hash="7ae57f8b115f99d72417917fb323dec3"/></dir></dir><dir name="etc"><file name="config.xml" hash="f804eafe8443e795744fa03d16df12d0"/></dir></dir></dir></target></contents>
16
  <compatible/>
17
-
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Wyomind_OrdersEraser</name>
4
+ <version>3.1.0</version>
5
  <stability>stable</stability>
6
  <license>GPL</license>
7
  <channel>community</channel>
9
  <summary>Orders eraser allows to simply clean your sales database by deleting any useless orders and linked invoices and/or shipping in once.</summary>
10
  <description>Orders eraser allows to simply clean your sales database by deleting any useless orders and linked invoices and/or shipping in once.</description>
11
  <notes>none</notes>
12
+ <authors><author><name>Wyomind</name><user>auto-converted</user><email>contact@wyomind.com</email></author></authors>
13
  <date>2012-04-10</date>
14
+ <time>14:09:44</time>
15
+ <contents><target name="mageetc"><dir name="modules"><file name="Wyomind_Orderseraser.xml" hash="43aa1ed1daf4f94fee1dddde51b9160c"/></dir></target><target name="magecommunity"><dir name="Wyomind"><dir name="Orderseraser"><dir name="Block"><dir name="Order"><file name="Grid.php" hash="4005a0d98668faa75bb080abc27008ba"/></dir></dir><dir name="Model"><file name="Orderseraser.php" hash="bab81858937f932c1f59bdc1205d15c4"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="OrderseraserController.php" hash="c33cb6afd271284d56b200a01f6b4d20"/></dir></dir><dir name="etc"><file name="config.xml" hash="cd069dbe7df58db7535ee6ba89eb1eb1"/></dir></dir></dir></target></contents>
16
  <compatible/>
17
+ <dependencies/>
18
  </package>