Wyomind_OrdersEraser - Version 3.1.1

Version Notes

none

Download this release

Release Info

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


Code changes from version 3.0.1 to 3.1.1

app/code/community/Wyomind/Orderseraser/Block/Order/Grid.php CHANGED
@@ -1 +1 @@
1
- <?php
2
  public function __construct() {
3
  parent::__construct();
4
 
5
  }
6
 
7
  protected function _prepareCollection() {
8
 
9
  $actions = array();
10
  if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
11
  $actions[] = array(
12
  'caption' => Mage::helper('sales')->__('View'),
13
  'url' => array('base' => '*/sales_order/view'),
14
  'field' => 'order_id'
15
  );
16
  }
17
  if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/delete')) {
18
  $actions[] = array(
19
  'caption' => Mage::helper('sales')->__('Delete'),
20
  'url' => array('base' => 'orderseraser/adminhtml_orderseraser/delete'),
21
  'confirm' => Mage::helper('sales')->__('Are your sure your want to delete this order and to erase all linked data ? '),
22
  'field' => 'order_id'
23
  );
24
  }
25
  $this->addColumn('action', array(
26
  'header' => Mage::helper('sales')->__('Action'),
27
  'width' => '50px',
28
  'type' => 'action',
29
  'getter' => 'getId',
30
  'actions' => $actions,
31
  'filter' => false,
32
  'sortable' => false,
33
  'index' => 'stores',
34
  'is_system' => true,
35
  ));
36
 
37
  return parent::_prepareCollection();
38
  }
39
 
40
  protected function _prepareColumns() {
41
  return parent::_prepareColumns();
42
  }
43
  protected function _prepareMassaction() {
44
 
45
  parent::_prepareMassaction();
46
  if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/delete')) {
47
  $this->getMassactionBlock()->addItem('delete_order', array(
48
  'label' => Mage::helper('sales')->__('Delete'),
49
  'url' => $this->getUrl('orderseraser/adminhtml_orderseraser/massdelete'),
50
  ));
51
  }
52
  return $this;
53
  }
 
 
1
  public function __construct() {
2
  parent::__construct();
3
 
4
  }
5
 
6
  protected function _prepareCollection() {
7
 
8
  $actions = array();
9
  if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
10
  $actions[] = array(
11
  'caption' => Mage::helper('sales')->__('View'),
12
  'url' => array('base' => '*/sales_order/view'),
13
  'field' => 'order_id'
14
  );
15
  }
16
  if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/delete')) {
17
  $actions[] = array(
18
  'caption' => Mage::helper('sales')->__('Delete'),
19
  'url' => array('base' => 'orderseraser/adminhtml_orderseraser/delete'),
20
  'confirm' => Mage::helper('sales')->__('Are your sure your want to delete this order and to erase all linked data ? '),
21
  'field' => 'order_id'
22
  );
23
  }
24
  $this->addColumn('action', array(
25
  'header' => Mage::helper('sales')->__('Action'),
26
  'width' => '50px',
27
  'type' => 'action',
28
  'getter' => 'getId',
29
  'actions' => $actions,
30
  'filter' => false,
31
  'sortable' => false,
32
  'index' => 'stores',
33
  'is_system' => true,
34
  ));
35
 
36
  return parent::_prepareCollection();
37
  }
38
 
39
  protected function _prepareColumns() {
40
  return parent::_prepareColumns();
41
  }
42
  protected function _prepareMassaction() {
43
 
44
  parent::_prepareMassaction();
45
  if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/delete')) {
46
  $this->getMassactionBlock()->addItem('delete_order', array(
47
  'label' => Mage::helper('sales')->__('Delete'),
48
  'url' => $this->getUrl('orderseraser/adminhtml_orderseraser/massdelete'),
49
  ));
50
  }
51
  return $this;
52
  }
53
+ <?phpclass Wyomind_Orderseraser_Block_Order_Grid extends Mage_Adminhtml_Block_Sales_Order_Grid { public function __construct() { parent::__construct(); } protected function _prepareCollection() { $actions = array(); if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) { $actions[] = array( 'caption' => Mage::helper('sales')->__('View'), 'url' => array('base' => '*/sales_order/view'), 'field' => 'order_id' ); } if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/delete')) { $actions[] = array( 'caption' => Mage::helper('sales')->__('Delete'), 'url' => array('base' => 'orderseraser/adminhtml_orderseraser/delete'), 'confirm' => Mage::helper('sales')->__('Are your sure your want to delete this order and to erase all linked data ? '), 'field' => 'order_id' ); } $this->addColumn('action', array( 'header' => Mage::helper('sales')->__('Action'), 'width' => '50px', 'type' => 'action', 'getter' => 'getId', 'actions' => $actions, 'filter' => false, 'sortable' => false, 'index' => 'stores', 'is_system' => true, )); return parent::_prepareCollection(); } protected function _prepareColumns() { return parent::_prepareColumns(); } protected function _prepareMassaction() { parent::_prepareMassaction(); if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/delete')) { $this->getMassactionBlock()->addItem('delete_order', array( 'label' => Mage::helper('sales')->__('Delete'), 'url' => $this->getUrl('orderseraser/adminhtml_orderseraser/massdelete'), )); } return $this; }}
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
@@ -7,7 +7,7 @@
7
 
8
  <Wyomind_Orderseraser>
9
 
10
- <version>3.0.1</version>
11
 
12
  </Wyomind_Orderseraser>
13
 
7
 
8
  <Wyomind_Orderseraser>
9
 
10
+ <version>3.1.1</version>
11
 
12
  </Wyomind_Orderseraser>
13
 
app/etc/modules/Wyomind_Orderseraser.xml DELETED
@@ -1,18 +0,0 @@
1
- <?xml version="1.0"?>
2
-
3
-
4
- <config>
5
-
6
- <modules>
7
-
8
- <Wyomind_Orderseraser>
9
-
10
- <active>true</active>
11
-
12
- <codePool>community</codePool>
13
-
14
- </Wyomind_Orderseraser>
15
-
16
- </modules>
17
-
18
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.1</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="magecommunity"><dir name="Wyomind"><dir name="Orderseraser"><dir name="Block"><dir name="Order"><file name="Grid.php" hash="6aa448fcf6e45a3056d0742621c40ed8"/></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="b5d7d6b5186df521195a1fe569b577d1"/></dir></dir></dir></target></contents>
16
  <compatible/>
17
+ <dependencies/>
18
  </package>