Version Notes
Repack
Download this release
Release Info
Developer | Magento Core Team |
Extension | Delete_Orders |
Version | 1.0.8610 |
Comparing to | |
See all releases |
Version 1.0.8610
- app/code/community/Mageex/DeleteOrders/Block/Grid.php +59 -0
- app/code/community/Mageex/DeleteOrders/Block/View.php +227 -0
- app/code/community/Mageex/DeleteOrders/Model/Address.php +10 -0
- app/code/community/Mageex/DeleteOrders/Model/Item.php +10 -0
- app/code/community/Mageex/DeleteOrders/Model/Mysql4/Address.php +9 -0
- app/code/community/Mageex/DeleteOrders/Model/Mysql4/Address/Collection.php +10 -0
- app/code/community/Mageex/DeleteOrders/Model/Mysql4/Item.php +9 -0
- app/code/community/Mageex/DeleteOrders/Model/Mysql4/Item/Collection.php +10 -0
- app/code/community/Mageex/DeleteOrders/Model/Mysql4/Quote.php +9 -0
- app/code/community/Mageex/DeleteOrders/Model/Mysql4/Quote/Collection.php +10 -0
- app/code/community/Mageex/DeleteOrders/Model/Quote.php +10 -0
- app/code/community/Mageex/DeleteOrders/controllers/IndexController.php +168 -0
- app/code/community/Mageex/DeleteOrders/etc/config.xml +68 -0
- app/etc/modules/Mageex_Deleteorders.xml +9 -0
- package.xml +28 -0
app/code/community/Mageex/DeleteOrders/Block/Grid.php
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Mageex_Deleteorders_Block_Grid extends Mage_Adminhtml_Block_Sales_Order_Grid
|
3 |
+
{
|
4 |
+
protected function _prepareMassaction()
|
5 |
+
{
|
6 |
+
$this->setMassactionIdField('entity_id');
|
7 |
+
$this->getMassactionBlock()->setFormFieldName('order_ids');
|
8 |
+
$this->getMassactionBlock()->setUseSelectAll(false);
|
9 |
+
|
10 |
+
if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/cancel')) {
|
11 |
+
$this->getMassactionBlock()->addItem('cancel_order', array(
|
12 |
+
'label'=> Mage::helper('sales')->__('Cancel'),
|
13 |
+
'url' => $this->getUrl('*/sales_order/massCancel'),
|
14 |
+
));
|
15 |
+
}
|
16 |
+
|
17 |
+
if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/hold')) {
|
18 |
+
$this->getMassactionBlock()->addItem('hold_order', array(
|
19 |
+
'label'=> Mage::helper('sales')->__('Hold'),
|
20 |
+
'url' => $this->getUrl('*/sales_order/massHold'),
|
21 |
+
));
|
22 |
+
}
|
23 |
+
|
24 |
+
if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/unhold')) {
|
25 |
+
$this->getMassactionBlock()->addItem('unhold_order', array(
|
26 |
+
'label'=> Mage::helper('sales')->__('Unhold'),
|
27 |
+
'url' => $this->getUrl('*/sales_order/massUnhold'),
|
28 |
+
));
|
29 |
+
}
|
30 |
+
|
31 |
+
$this->getMassactionBlock()->addItem('pdfinvoices_order', array(
|
32 |
+
'label'=> Mage::helper('sales')->__('Print Invoices'),
|
33 |
+
'url' => $this->getUrl('*/sales_order/pdfinvoices'),
|
34 |
+
));
|
35 |
+
|
36 |
+
$this->getMassactionBlock()->addItem('pdfshipments_order', array(
|
37 |
+
'label'=> Mage::helper('sales')->__('Print Packingslips'),
|
38 |
+
'url' => $this->getUrl('*/sales_order/pdfshipments'),
|
39 |
+
));
|
40 |
+
|
41 |
+
$this->getMassactionBlock()->addItem('pdfcreditmemos_order', array(
|
42 |
+
'label'=> Mage::helper('sales')->__('Print Credit Memos'),
|
43 |
+
'url' => $this->getUrl('*/sales_order/pdfcreditmemos'),
|
44 |
+
));
|
45 |
+
|
46 |
+
$this->getMassactionBlock()->addItem('pdfdocs_order', array(
|
47 |
+
'label'=> Mage::helper('sales')->__('Print All'),
|
48 |
+
'url' => $this->getUrl('*/sales_order/pdfdocs'),
|
49 |
+
));
|
50 |
+
|
51 |
+
$this->getMassactionBlock()->addItem('delete_order', array(
|
52 |
+
'label'=> Mage::helper('sales')->__('Delete'),
|
53 |
+
'url' => $this->getUrl('*/*/delete'),
|
54 |
+
));
|
55 |
+
|
56 |
+
return $this;
|
57 |
+
}
|
58 |
+
}
|
59 |
+
?>
|
app/code/community/Mageex/DeleteOrders/Block/View.php
ADDED
@@ -0,0 +1,227 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Mageex_Deleteorders_Block_View extends Mage_Adminhtml_Block_Widget_Form_Container
|
3 |
+
{
|
4 |
+
public function __construct()
|
5 |
+
{
|
6 |
+
$this->_objectId = 'order_id';
|
7 |
+
$this->_controller = 'sales_order';
|
8 |
+
$this->_mode = 'view';
|
9 |
+
|
10 |
+
parent::__construct();
|
11 |
+
|
12 |
+
$this->_removeButton('delete');
|
13 |
+
$this->_removeButton('reset');
|
14 |
+
$this->_removeButton('save');
|
15 |
+
$this->setId('sales_order_view');
|
16 |
+
$order = $this->getOrder();
|
17 |
+
|
18 |
+
if ($this->_isAllowedAction('edit') && $order->canEdit()) {
|
19 |
+
$onclickJs = 'deleteConfirm(\''
|
20 |
+
. Mage::helper('sales')->__('Are you sure? This order will be cancelled and a new one will be created instead')
|
21 |
+
. '\', \'' . $this->getEditUrl() . '\');';
|
22 |
+
$this->_addButton('order_edit', array(
|
23 |
+
'label' => Mage::helper('sales')->__('Edit'),
|
24 |
+
'onclick' => $onclickJs,
|
25 |
+
));
|
26 |
+
// see if order has non-editable products as items
|
27 |
+
$nonEditableTypes = array_keys(Mage::getResourceSingleton('sales/order')->aggregateProductsByTypes(
|
28 |
+
$order->getId(), array_keys(Mage::getConfig()->getNode('adminhtml/sales/order/create/available_product_types')->asArray()), false
|
29 |
+
));
|
30 |
+
if ($nonEditableTypes) {
|
31 |
+
$this->_updateButton('order_edit', 'onclick',
|
32 |
+
'if (!confirm(\'' .
|
33 |
+
Mage::helper('sales')->__('This order contains (%s) items and therefore cannot be edited through the admin interface at this time, if you wish to continue editing the (%s) items will be removed, the order will be cancelled and a new order will be placed', implode(', ', $nonEditableTypes), implode(', ', $nonEditableTypes)) . '\')) return false;' . $onclickJs
|
34 |
+
);
|
35 |
+
}
|
36 |
+
}
|
37 |
+
|
38 |
+
if ($this->_isAllowedAction('cancel') && $order->canCancel()) {
|
39 |
+
$message = Mage::helper('sales')->__('Are you sure you want to cancel this order?');
|
40 |
+
$this->_addButton('order_cancel', array(
|
41 |
+
'label' => Mage::helper('sales')->__('Cancel'),
|
42 |
+
'onclick' => 'deleteConfirm(\''.$message.'\', \'' . $this->getCancelUrl() . '\')',
|
43 |
+
));
|
44 |
+
}
|
45 |
+
$message = Mage::helper('sales')->__('Are you sure you want to delete this order ?');
|
46 |
+
$this->_addButton('order_delete', array(
|
47 |
+
'label' => Mage::helper('sales')->__('Delete'),
|
48 |
+
'onclick' => 'deleteConfirm(\''.$message.'\', \'' . $this->getDeleteUrl() . '\')',
|
49 |
+
'class' => 'delete',
|
50 |
+
));
|
51 |
+
|
52 |
+
|
53 |
+
|
54 |
+
if ($this->_isAllowedAction('emails') && !$order->isCanceled()) {
|
55 |
+
$message = Mage::helper('sales')->__('Are you sure you want to send order email to customer?');
|
56 |
+
$this->addButton('send_notification', array(
|
57 |
+
'label' => Mage::helper('sales')->__('Send Email'),
|
58 |
+
'onclick' => "confirmSetLocation('{$message}', '{$this->getEmailUrl()}')",
|
59 |
+
));
|
60 |
+
}
|
61 |
+
|
62 |
+
if ($this->_isAllowedAction('creditmemo') && $order->canCreditmemo()) {
|
63 |
+
$this->_addButton('order_creditmemo', array(
|
64 |
+
'label' => Mage::helper('sales')->__('Credit Memo...'),
|
65 |
+
'onclick' => 'setLocation(\'' . $this->getCreditmemoUrl() . '\')',
|
66 |
+
));
|
67 |
+
}
|
68 |
+
|
69 |
+
// invoice action intentionally
|
70 |
+
if ($this->_isAllowedAction('invoice') && $order->canVoidPayment()) {
|
71 |
+
$message = Mage::helper('sales')->__('Are you sure you want to void the payment?');
|
72 |
+
$this->addButton('void_payment', array(
|
73 |
+
'label' => Mage::helper('sales')->__('Void'),
|
74 |
+
'onclick' => "confirmSetLocation('{$message}', '{$this->getVoidPaymentUrl()}')",
|
75 |
+
));
|
76 |
+
}
|
77 |
+
|
78 |
+
if ($this->_isAllowedAction('hold') && $order->canHold()) {
|
79 |
+
$this->_addButton('order_hold', array(
|
80 |
+
'label' => Mage::helper('sales')->__('Hold'),
|
81 |
+
'onclick' => 'setLocation(\'' . $this->getHoldUrl() . '\')',
|
82 |
+
));
|
83 |
+
}
|
84 |
+
|
85 |
+
if ($this->_isAllowedAction('unhold') && $order->canUnhold()) {
|
86 |
+
$this->_addButton('order_unhold', array(
|
87 |
+
'label' => Mage::helper('sales')->__('Unhold'),
|
88 |
+
'onclick' => 'setLocation(\'' . $this->getUnholdUrl() . '\')',
|
89 |
+
));
|
90 |
+
}
|
91 |
+
|
92 |
+
if ($this->_isAllowedAction('invoice') && $order->canInvoice()) {
|
93 |
+
$_label = $order->getForcedDoShipmentWithInvoice() ?
|
94 |
+
Mage::helper('sales')->__('Invoice and Ship...') :
|
95 |
+
Mage::helper('sales')->__('Invoice...');
|
96 |
+
$this->_addButton('order_invoice', array(
|
97 |
+
'label' => $_label,
|
98 |
+
'onclick' => 'setLocation(\'' . $this->getInvoiceUrl() . '\')',
|
99 |
+
));
|
100 |
+
}
|
101 |
+
|
102 |
+
if ($this->_isAllowedAction('ship') && $order->canShip()
|
103 |
+
&& !$order->getForcedDoShipmentWithInvoice()) {
|
104 |
+
$this->_addButton('order_ship', array(
|
105 |
+
'label' => Mage::helper('sales')->__('Ship...'),
|
106 |
+
'onclick' => 'setLocation(\'' . $this->getShipUrl() . '\')',
|
107 |
+
));
|
108 |
+
}
|
109 |
+
|
110 |
+
if ($this->_isAllowedAction('reorder') && $order->canReorder()) {
|
111 |
+
$this->_addButton('order_reorder', array(
|
112 |
+
'label' => Mage::helper('sales')->__('Reorder...'),
|
113 |
+
'onclick' => 'setLocation(\'' . $this->getReorderUrl() . '\')',
|
114 |
+
));
|
115 |
+
}
|
116 |
+
}
|
117 |
+
|
118 |
+
/**
|
119 |
+
* Retrieve order model object
|
120 |
+
*
|
121 |
+
* @return Mage_Sales_Model_Order
|
122 |
+
*/
|
123 |
+
public function getOrder()
|
124 |
+
{
|
125 |
+
return Mage::registry('sales_order');
|
126 |
+
}
|
127 |
+
|
128 |
+
/**
|
129 |
+
* Retrieve Order Identifier
|
130 |
+
*
|
131 |
+
* @return int
|
132 |
+
*/
|
133 |
+
public function getOrderId()
|
134 |
+
{
|
135 |
+
return $this->getOrder()->getId();
|
136 |
+
}
|
137 |
+
|
138 |
+
public function getHeaderText()
|
139 |
+
{
|
140 |
+
if ($_extOrderId = $this->getOrder()->getExtOrderId()) {
|
141 |
+
$_extOrderId = '[' . $_extOrderId . '] ';
|
142 |
+
} else {
|
143 |
+
$_extOrderId = '';
|
144 |
+
}
|
145 |
+
$text = Mage::helper('sales')->__('Order # %s %s| Order Date %s',
|
146 |
+
$this->getOrder()->getRealOrderId(),
|
147 |
+
$_extOrderId,
|
148 |
+
$this->formatDate($this->getOrder()->getCreatedAtDate(), 'medium', true)
|
149 |
+
);
|
150 |
+
return $text;
|
151 |
+
}
|
152 |
+
|
153 |
+
public function getUrl($params='', $params2=array())
|
154 |
+
{
|
155 |
+
$params2['order_id'] = $this->getOrderId();
|
156 |
+
return parent::getUrl($params, $params2);
|
157 |
+
}
|
158 |
+
|
159 |
+
public function getEditUrl()
|
160 |
+
{
|
161 |
+
return $this->getUrl('*/sales_order_edit/start');
|
162 |
+
}
|
163 |
+
|
164 |
+
public function getEmailUrl()
|
165 |
+
{
|
166 |
+
return $this->getUrl('*/*/email');
|
167 |
+
}
|
168 |
+
|
169 |
+
public function getCancelUrl()
|
170 |
+
{
|
171 |
+
return $this->getUrl('*/*/cancel');
|
172 |
+
}
|
173 |
+
|
174 |
+
public function getDeleteUrl()
|
175 |
+
{
|
176 |
+
return $this->getUrl('*/*/delete');
|
177 |
+
}
|
178 |
+
|
179 |
+
public function getInvoiceUrl()
|
180 |
+
{
|
181 |
+
return $this->getUrl('*/sales_order_invoice/start');
|
182 |
+
}
|
183 |
+
|
184 |
+
public function getCreditmemoUrl()
|
185 |
+
{
|
186 |
+
return $this->getUrl('*/sales_order_creditmemo/start');
|
187 |
+
}
|
188 |
+
|
189 |
+
public function getHoldUrl()
|
190 |
+
{
|
191 |
+
return $this->getUrl('*/*/hold');
|
192 |
+
}
|
193 |
+
|
194 |
+
public function getUnholdUrl()
|
195 |
+
{
|
196 |
+
return $this->getUrl('*/*/unhold');
|
197 |
+
}
|
198 |
+
|
199 |
+
public function getShipUrl()
|
200 |
+
{
|
201 |
+
return $this->getUrl('*/sales_order_shipment/start');
|
202 |
+
}
|
203 |
+
|
204 |
+
public function getCommentUrl()
|
205 |
+
{
|
206 |
+
return $this->getUrl('*/*/comment');
|
207 |
+
}
|
208 |
+
|
209 |
+
public function getReorderUrl()
|
210 |
+
{
|
211 |
+
return $this->getUrl('*/sales_order_create/reorder');
|
212 |
+
}
|
213 |
+
|
214 |
+
/**
|
215 |
+
* Payment void URL getter
|
216 |
+
*/
|
217 |
+
public function getVoidPaymentUrl()
|
218 |
+
{
|
219 |
+
return $this->getUrl('*/*/voidPayment');
|
220 |
+
}
|
221 |
+
|
222 |
+
protected function _isAllowedAction($action)
|
223 |
+
{
|
224 |
+
return Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/' . $action);
|
225 |
+
}
|
226 |
+
}
|
227 |
+
?>
|
app/code/community/Mageex/DeleteOrders/Model/Address.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Mageex_Deleteorders_Model_Address extends Mage_Core_Model_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
parent::_construct();
|
8 |
+
$this->_init('deleteorders/address');
|
9 |
+
}
|
10 |
+
}
|
app/code/community/Mageex/DeleteOrders/Model/Item.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Mageex_Deleteorders_Model_Item extends Mage_Core_Model_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
parent::_construct();
|
8 |
+
$this->_init('deleteorders/item');
|
9 |
+
}
|
10 |
+
}
|
app/code/community/Mageex/DeleteOrders/Model/Mysql4/Address.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Mageex_Deleteorders_Model_Mysql4_Address extends Mage_Core_Model_Mysql4_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
$this->_init('deleteorders/address', 'address_id');
|
8 |
+
}
|
9 |
+
}
|
app/code/community/Mageex/DeleteOrders/Model/Mysql4/Address/Collection.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Mageex_Deleteorders_Model_Mysql4_Address_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
parent::_construct();
|
8 |
+
$this->_init('deleteorders/address');
|
9 |
+
}
|
10 |
+
}
|
app/code/community/Mageex/DeleteOrders/Model/Mysql4/Item.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Mageex_Deleteorders_Model_Mysql4_Item extends Mage_Core_Model_Mysql4_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
$this->_init('deleteorders/item', 'item_id');
|
8 |
+
}
|
9 |
+
}
|
app/code/community/Mageex/DeleteOrders/Model/Mysql4/Item/Collection.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Mageex_Deleteorders_Model_Mysql4_Item_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
parent::_construct();
|
8 |
+
$this->_init('deleteorders/item');
|
9 |
+
}
|
10 |
+
}
|
app/code/community/Mageex/DeleteOrders/Model/Mysql4/Quote.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Mageex_Deleteorders_Model_Mysql4_Quote extends Mage_Core_Model_Mysql4_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
$this->_init('deleteorders/quote', 'entity_id');
|
8 |
+
}
|
9 |
+
}
|
app/code/community/Mageex/DeleteOrders/Model/Mysql4/Quote/Collection.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Mageex_Deleteorders_Model_Mysql4_Quote_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
parent::_construct();
|
8 |
+
$this->_init('deleteorders/quote');
|
9 |
+
}
|
10 |
+
}
|
app/code/community/Mageex/DeleteOrders/Model/Quote.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Mageex_Deleteorders_Model_Quote extends Mage_Core_Model_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
parent::_construct();
|
8 |
+
$this->_init('deleteorders/quote');
|
9 |
+
}
|
10 |
+
}
|
app/code/community/Mageex/DeleteOrders/controllers/IndexController.php
ADDED
@@ -0,0 +1,168 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
require_once 'app/code/core/Mage/Adminhtml/controllers/Sales/OrderController.php';
|
3 |
+
class Mageex_Deleteorders_IndexController extends Mage_Adminhtml_Sales_OrderController
|
4 |
+
{
|
5 |
+
public function deleteAction()
|
6 |
+
{
|
7 |
+
//$orderIds = $this->getRequest()->getPost('order_ids', array());
|
8 |
+
|
9 |
+
$model = Mage::getModel('sales/order');
|
10 |
+
$quote = Mage::getModel('deleteorders/quote');
|
11 |
+
$address = Mage::getModel('deleteorders/address');
|
12 |
+
$option = Mage::getModel('deleteorders/item');
|
13 |
+
|
14 |
+
$resource = Mage::getSingleton('core/resource');
|
15 |
+
$read = $resource->getConnection('catalog_read');
|
16 |
+
|
17 |
+
|
18 |
+
$salesFlatCredit = $resource->getTableName('sales_flat_creditmemo'); //order_id
|
19 |
+
$salesFlatCrGrid = $resource->getTableName('sales_flat_creditmemo_grid'); //order_id
|
20 |
+
$salesFlatInvoice = $resource->getTableName('sales_flat_invoice'); //order_id
|
21 |
+
$salesFlatInGrid = $resource->getTableName('sales_flat_invoice_grid'); //order_id
|
22 |
+
$salesFlatOrderItem = $resource->getTableName('sales_flat_order_item'); //order_id
|
23 |
+
$salesFlatShip = $resource->getTableName('sales_flat_shipment'); //order_id
|
24 |
+
$salesFlatShipGrid = $resource->getTableName('sales_flat_shipment_grid'); //order_id
|
25 |
+
|
26 |
+
$salesFlatCrItem = $resource->getTableName('sales_flat_creditmemo_item'); //order_item_id
|
27 |
+
$salesFlatInItem = $resource->getTableName('sales_flat_invoice_grid'); //order_item_id
|
28 |
+
$salesFlatShipItem = $resource->getTableName('sales_flat_shipment_item'); //order_item_id
|
29 |
+
|
30 |
+
$salesFlatOrder = $resource->getTableName('sales_flat_order'); //entity_id
|
31 |
+
|
32 |
+
$salesFlatOrderAdd = $resource->getTableName('sales_flat_order_address'); //parent_id
|
33 |
+
$salesFlatOrderPay = $resource->getTableName('sales_flat_order_payment');//parent_id
|
34 |
+
$salesFlatOrderSHis = $resource->getTableName('sales_flat_order_status_history'); //parent_id
|
35 |
+
|
36 |
+
$salesFlatQuoteAdd = $resource->getTableName('sales_flat_quote_address'); //quote_id
|
37 |
+
$salesFlatQuoteItem = $resource->getTableName('sales_flat_quote_item');// quote_id
|
38 |
+
$salesFlatQuoPay = $resource->getTableName('sales_flat_quote_payment'); //quote_id
|
39 |
+
|
40 |
+
$salesFlatQuoItOp = $resource->getTableName('sales_flat_quote_item_option');// item_id
|
41 |
+
|
42 |
+
$salesFlatQuoShRate = $resource->getTableName('sales_flat_quote_shipping_rate'); //rate_id
|
43 |
+
|
44 |
+
$salesFlatOrderGrid = $resource->getTableName('sales_flat_order_grid'); //increment_id
|
45 |
+
$salesFlatQuote = $resource->getTableName('sales_flat_quote'); //increment_id
|
46 |
+
|
47 |
+
$arrTableOrderId = array($salesFlatCredit, $salesFlatCrGrid, $salesFlatInvoice,
|
48 |
+
$salesFlatInGrid, $salesFlatOrderItem, $salesFlatShip, $salesFlatShipGrid);
|
49 |
+
|
50 |
+
$arrTableOrderItemId = array($salesFlatCrItem, $salesFlatInItem, $salesFlatShipItem);
|
51 |
+
|
52 |
+
$arrTableParentId = array($salesFlatOrderAdd, $salesFlatOrderPay, $salesFlatOrderSHis);
|
53 |
+
|
54 |
+
$arrTableQuoteId = array($salesFlatQuoteAdd, $salesFlatQuoteItem, $salesFlatQuoPay);
|
55 |
+
|
56 |
+
if($orderIds = $this->getRequest()->getPost('order_ids', array())){
|
57 |
+
if(count($orderIds)>0){
|
58 |
+
try{
|
59 |
+
foreach($orderIds as $item){
|
60 |
+
$order = $model->load($item);
|
61 |
+
$incrementId = (string)$order->getIncrementId();
|
62 |
+
$rs = $read->query('delete from '.$salesFlatOrder.' where entity_id='.$item);
|
63 |
+
foreach($arrTableOrderId as $table){
|
64 |
+
$rs = $read->query('delete from '.$table.' where order_id='.$item);
|
65 |
+
}
|
66 |
+
$rs = $read->query('delete from '.$salesFlatOrderGrid.' where increment_id = "'.$incrementId.'"');
|
67 |
+
$quoteCollection = $quote->getCollection()->addFieldToFilter('reserved_order_id', $incrementId);
|
68 |
+
|
69 |
+
foreach($quoteCollection as $_quote){
|
70 |
+
$_quoteId = $_quote->getEntityId();
|
71 |
+
//Delete from sales_flat_quote_shipping_rate table
|
72 |
+
$addressCollection = $address->getCollection()->addFieldToFilter('quote_id', $_quoteId);
|
73 |
+
foreach($addressCollection as $_address){
|
74 |
+
$addressId = $_address->getAddressId();
|
75 |
+
$rs = $read->query('delete from '.$salesFlatQuoShRate.' where address_id='.$addressId);
|
76 |
+
}
|
77 |
+
|
78 |
+
//Delete from sales_flat_quote_item_option table
|
79 |
+
$itemCollection = $option->getCollection()->addFieldToFilter('quote_id', $_quoteId);
|
80 |
+
foreach($itemCollection as $_item){
|
81 |
+
$itemId = $_item->getItemId();
|
82 |
+
$rs = $read->query('delete from '.$salesFlatQuoItOp.' where item_id='.$itemId);
|
83 |
+
}
|
84 |
+
|
85 |
+
foreach($arrTableQuoteId as $table){
|
86 |
+
$rs = $read->query('delete from '.$table.' where quote_id='.$_quoteId);
|
87 |
+
}
|
88 |
+
}
|
89 |
+
|
90 |
+
//Delete from sales_flat_quote
|
91 |
+
$rs = $read->query('delete from '.$salesFlatQuote.' where reserved_order_id = "'.$incrementId.'"');
|
92 |
+
foreach($arrTableOrderItemId as $table){
|
93 |
+
$rs = $read->query('delete from '.$table.' where order_item_id='.$item);
|
94 |
+
}
|
95 |
+
|
96 |
+
foreach($arrTableParentId as $table){
|
97 |
+
$rs = $read->query('delete from '.$table.' where parent_id='.$item);
|
98 |
+
}
|
99 |
+
}
|
100 |
+
|
101 |
+
}
|
102 |
+
catch(Exception $e){
|
103 |
+
|
104 |
+
}
|
105 |
+
|
106 |
+
if(count($orderIds)>1)
|
107 |
+
$this->_getSession()->addSuccess($this->__('%s order(s) have been deleted.', count($orderIds)));
|
108 |
+
else
|
109 |
+
$this->_getSession()->addSuccess($this->__('The order has been deleted'));
|
110 |
+
}
|
111 |
+
else{
|
112 |
+
$this->_getSession()->addError($this->__('Please select items.'));
|
113 |
+
}
|
114 |
+
}
|
115 |
+
else{
|
116 |
+
$orderId = $this->getRequest()->getParam('order_id');
|
117 |
+
$order = $model->load($orderId);
|
118 |
+
$incrementId = (string)$order->getIncrementId();
|
119 |
+
try{
|
120 |
+
$rs = $read->query('delete from '.$salesFlatOrder.' where entity_id='.$orderId);
|
121 |
+
|
122 |
+
foreach($arrTableOrderId as $table){
|
123 |
+
$rs = $read->query('delete from '.$table.' where order_id='.$orderId);
|
124 |
+
}
|
125 |
+
$rs = $read->query('delete from '.$salesFlatOrderGrid.' where increment_id = "'.$incrementId.'"');
|
126 |
+
|
127 |
+
$quoteCollection = $quote->getCollection()->addFieldToFilter('reserved_order_id', $incrementId);
|
128 |
+
|
129 |
+
foreach($quoteCollection as $_quote){
|
130 |
+
$_quoteId = $_quote->getEntityId();
|
131 |
+
//Delete from sales_flat_quote_shipping_rate table
|
132 |
+
$addressCollection = $address->getCollection()->addFieldToFilter('quote_id', $_quoteId);
|
133 |
+
foreach($addressCollection as $_address){
|
134 |
+
$addressId = $_address->getAddressId();
|
135 |
+
$rs = $read->query('delete from '.$salesFlatQuoShRate.' where address_id='.$addressId);
|
136 |
+
}
|
137 |
+
|
138 |
+
//Delete from sales_flat_quote_item_option table
|
139 |
+
$itemCollection = $option->getCollection()->addFieldToFilter('quote_id', $_quoteId);
|
140 |
+
foreach($itemCollection as $_item){
|
141 |
+
$itemId = $_item->getItemId();
|
142 |
+
$rs = $read->query('delete from '.$salesFlatQuoItOp.' where item_id='.$itemId);
|
143 |
+
}
|
144 |
+
|
145 |
+
foreach($arrTableQuoteId as $table){
|
146 |
+
$rs = $read->query('delete from '.$table.' where quote_id='.$_quoteId);
|
147 |
+
}
|
148 |
+
}
|
149 |
+
|
150 |
+
//Delete from sales_flat_quote
|
151 |
+
$rs = $read->query('delete from '.$salesFlatQuote.' where reserved_order_id = "'.$incrementId.'"');
|
152 |
+
|
153 |
+
foreach($arrTableOrderItemId as $table){
|
154 |
+
$rs = $read->query('delete from '.$table.' where order_item_id='.$orderId);
|
155 |
+
}
|
156 |
+
|
157 |
+
foreach($arrTableParentId as $table){
|
158 |
+
$rs = $read->query('delete from '.$table.' where parent_id='.$orderId);
|
159 |
+
}
|
160 |
+
}
|
161 |
+
catch(Exception $e){
|
162 |
+
|
163 |
+
}
|
164 |
+
$this->_getSession()->addSuccess($this->__('The order has been deleted'));
|
165 |
+
}
|
166 |
+
$this->_redirect('*/*/');
|
167 |
+
}
|
168 |
+
}
|
app/code/community/Mageex/DeleteOrders/etc/config.xml
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
|
3 |
+
<config>
|
4 |
+
<modules>
|
5 |
+
<Mageex_Deleteorders>
|
6 |
+
<version>0.1.0</version>
|
7 |
+
</Mageex_Deleteorders>
|
8 |
+
</modules>
|
9 |
+
<admin>
|
10 |
+
<routers>
|
11 |
+
<deleteorders>
|
12 |
+
<use>admin</use>
|
13 |
+
<args>
|
14 |
+
<module>Mageex_Deleteorders</module>
|
15 |
+
<frontName>deleteorders</frontName>
|
16 |
+
</args>
|
17 |
+
</deleteorders>
|
18 |
+
</routers>
|
19 |
+
</admin>
|
20 |
+
<global>
|
21 |
+
<blocks>
|
22 |
+
<adminhtml>
|
23 |
+
<rewrite>
|
24 |
+
<sales_order_grid>Mageex_Deleteorders_Block_Grid</sales_order_grid>
|
25 |
+
<sales_order_view>Mageex_Deleteorders_Block_View</sales_order_view>
|
26 |
+
</rewrite>
|
27 |
+
</adminhtml>
|
28 |
+
</blocks>
|
29 |
+
|
30 |
+
<models>
|
31 |
+
<deleteorders>
|
32 |
+
<class>Mageex_Deleteorders_Model</class>
|
33 |
+
<resourceModel>deleteorders_mysql4</resourceModel>
|
34 |
+
</deleteorders>
|
35 |
+
<deleteorders_mysql4>
|
36 |
+
<class>Mageex_Deleteorders_Model_Mysql4</class>
|
37 |
+
<entities>
|
38 |
+
<quote>
|
39 |
+
<table>sales_flat_quote</table>
|
40 |
+
</quote>
|
41 |
+
<address>
|
42 |
+
<table>sales_flat_quote_address</table>
|
43 |
+
</address>
|
44 |
+
<item>
|
45 |
+
<table>sales_flat_quote_item</table>
|
46 |
+
</item>
|
47 |
+
</entities>
|
48 |
+
</deleteorders_mysql4>
|
49 |
+
</models>
|
50 |
+
|
51 |
+
<rewrite>
|
52 |
+
<mageex_delete_index>
|
53 |
+
<from><![CDATA[#^/admin/sales_order/delete/#]]></from>
|
54 |
+
<to>/deleteorders/index/delete/</to>
|
55 |
+
</mageex_delete_index>
|
56 |
+
</rewrite>
|
57 |
+
|
58 |
+
</global>
|
59 |
+
<adminhtml>
|
60 |
+
<layout>
|
61 |
+
<updates>
|
62 |
+
<deleteorders>
|
63 |
+
<file>deleteorders.xml</file>
|
64 |
+
</deleteorders>
|
65 |
+
</updates>
|
66 |
+
</layout>
|
67 |
+
</adminhtml>
|
68 |
+
</config>
|
app/etc/modules/Mageex_Deleteorders.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Mageex_Deleteorders>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
</Mageex_Deleteorders>
|
8 |
+
</modules>
|
9 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Delete_Orders</name>
|
4 |
+
<version>1.0.8610</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>This extension helps you to absolutely delete false or bad orders.</summary>
|
10 |
+
<description>This extension helps you to absolutely delete false or bad orders. In addition, this extension also deletes other details with order like Invoices, Credit Memos, Shipment.
|
11 |
+
|
12 |
+
Note : Please pay your attention, this module need a little customize to work well with custom Admin URL (default is http://www.yourwebsite.com/index.php/admin)
|
13 |
+
|
14 |
+
Please change line 31 in app/code/local/Halo/DeleteOrders/etc
|
15 |
+
|
16 |
+
original :
|
17 |
+
<from><![CDATA[#^/admin/sales_order/delete/.*#]]></from>
|
18 |
+
|
19 |
+
change to :
|
20 |
+
<from><![CDATA[#^/your_custom_admin_url/sales_order/delete/.*#]]></from></description>
|
21 |
+
<notes>Repack</notes>
|
22 |
+
<authors><author><name>Nguyen Hoang</name><user>auto-converted</user><email>hien.tran@mageex.com</email></author></authors>
|
23 |
+
<date>2011-06-07</date>
|
24 |
+
<time>08:30:59</time>
|
25 |
+
<contents><target name="magecommunity"><dir name="Mageex"><dir name="DeleteOrders"><dir name="Block"><file name="Grid.php" hash="f71e88745355e6df232356482138bdd4"/><file name="View.php" hash="5c0fc1186c34dba90c1e53cc3ea948ae"/></dir><dir name="controllers"><file name="IndexController.php" hash="021d51668ce535450f5d353539af6a74"/></dir><dir name="etc"><file name="config.xml" hash="807fe63f84f723e721b213f77f8eb6a6"/></dir><dir name="Model"><file name="Address.php" hash="079b57a6f0f498ffc439a7f5d991ac52"/><file name="Item.php" hash="f1d29190e0a6af2cbdf502941f16ee15"/><file name="Quote.php" hash="869ccb766884d2f4a8bc5425088b6f8a"/><dir name="Mysql4"><file name="Address.php" hash="ad59889b6c376d826f6c8078f9389602"/><file name="Item.php" hash="61f4bb18b0459e14191f7f1507f34e93"/><file name="Quote.php" hash="bf8648acc64a1eb25eee507b880cdfd2"/><dir name="Address"><file name="Collection.php" hash="4e4f02b5caccb7e6068355b05eeb122e"/></dir><dir name="Item"><file name="Collection.php" hash="30bcef79a823b98bee608e6277aa3d0f"/></dir><dir name="Quote"><file name="Collection.php" hash="322a50f2711924291f687ca1cbe84c31"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Mageex_Deleteorders.xml" hash="60a0e619aff1279fad07b6ddd66bcfaa"/></dir></target></contents>
|
26 |
+
<compatible/>
|
27 |
+
<dependencies/>
|
28 |
+
</package>
|