Vp_Ordersku - Version 1.0.0

Version Notes

Extends order grid - add skus n products

Download this release

Release Info

Developer vpinfo
Extension Vp_Ordersku
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

app/code/local/Vp/Ordersku/Block/Adminhtml/Sales/Order/Grid.php ADDED
@@ -0,0 +1,291 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Vp_Ordersku_Block_Adminhtml_Sales_Order_Grid extends Mage_Adminhtml_Block_Widget_Grid
3
+ {
4
+
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+ $this->setId('sales_order_grid');
9
+ $this->setUseAjax(true);
10
+ $this->setDefaultSort('created_at');
11
+ $this->setDefaultDir('DESC');
12
+ $this->setSaveParametersInSession(true);
13
+ }
14
+
15
+ /**
16
+ * Retrieve collection class
17
+ *
18
+ * @return string
19
+ */
20
+ protected function _getCollectionClass()
21
+ {
22
+ return 'sales/order_grid_collection';
23
+ }
24
+
25
+ protected function _prepareCollection()
26
+ {
27
+ $collection = Mage::getResourceModel($this->_getCollectionClass())
28
+ ->join(
29
+ 'sales/order_item',
30
+ '`sales/order_item`.order_id=`main_table`.entity_id',
31
+ array(
32
+ 'skus' => new Zend_Db_Expr('group_concat(`sales/order_item`.sku SEPARATOR ",")'),
33
+ 'names' => new Zend_Db_Expr('group_concat(`sales/order_item`.name SEPARATOR ",")'),
34
+ 'qty' => new Zend_Db_Expr('group_concat(`sales/order_item`.qty_ordered SEPARATOR ",")'),
35
+ )
36
+ );
37
+ $collection->getSelect()->group('entity_id');
38
+ $this->setCollection($collection);
39
+ return parent::_prepareCollection();
40
+ }
41
+
42
+ public function filter_skus($collection, $column)
43
+ {
44
+ if (!$value = $column->getFilter()->getValue()) {
45
+ return $this;
46
+ }
47
+ $this->getCollection()->getSelect()->where(
48
+ "sku like ?"
49
+ , "%$value%");
50
+
51
+ return $this;
52
+ }
53
+
54
+ public function filter_names($collection, $column)
55
+ {
56
+ if (!$value = $column->getFilter()->getValue()) {
57
+ return $this;
58
+ }
59
+ $this->getCollection()->getSelect()->where(
60
+ "name like ?"
61
+ , "%$value%");
62
+
63
+ return $this;
64
+ }
65
+
66
+ public function filter_qty($collection, $column)
67
+ {
68
+ if (!$value = $column->getFilter()->getValue()) {
69
+ return $this;
70
+ }
71
+ $this->getCollection()->getSelect()->where(
72
+ "qty_ordered like ?"
73
+ , "%$value%");
74
+
75
+ return $this;
76
+ }
77
+
78
+ public function callback_skus($value, $row, $column, $isExport)
79
+ {
80
+ $increment_id = $value;
81
+ $_order = Mage::getModel('sales/order')->loadByIncrementId($increment_id);
82
+ $_items = $_order->getAllItems();
83
+ $skus="";
84
+ foreach ($_items as $item) {
85
+ $skus .= $item->getSku()."<br/>";
86
+ }
87
+ return $skus;
88
+ }
89
+
90
+ public function callback_qty($value, $row, $column, $isExport)
91
+ {
92
+ $increment_id = $value;
93
+ $_order = Mage::getModel('sales/order')->loadByIncrementId($increment_id);
94
+ $_items = $_order->getAllItems();
95
+ $qty="";
96
+ foreach ($_items as $item) {
97
+ $qty .= round($item->getQtyOrdered())."<br/>";
98
+ }
99
+ return $qty;
100
+ }
101
+
102
+ public function callback_names($value, $row, $column, $isExport)
103
+ {
104
+ $increment_id = $value;
105
+ $_order = Mage::getModel('sales/order')->loadByIncrementId($increment_id);
106
+ $_items = $_order->getAllItems();
107
+ $names="";
108
+ foreach ($_items as $item) {
109
+ $names .= $item->getName()."<br/>";
110
+ }
111
+ return $names;
112
+ }
113
+
114
+ protected function _prepareColumns()
115
+ {
116
+
117
+ $this->addColumn('real_order_id', array(
118
+ 'header'=> Mage::helper('sales')->__('Order #'),
119
+ 'width' => '80px',
120
+ 'type' => 'text',
121
+ 'index' => 'increment_id',
122
+ ));
123
+
124
+ $this->addColumn('sku', array(
125
+ 'header' => Mage::helper('sales')->__('SKU'),
126
+ 'index' => 'increment_id',
127
+ 'frame_callback' => array($this, 'callback_skus'),
128
+ 'filter_condition_callback' => array($this, 'filter_skus'),
129
+ ));
130
+
131
+ $this->addColumn('name', array(
132
+ 'header' => Mage::helper('sales')->__('Product Name'),
133
+ 'index' => 'increment_id',
134
+ 'frame_callback' => array($this, 'callback_names'),
135
+ 'filter_condition_callback' => array($this, 'filter_names'),
136
+ ));
137
+
138
+ $this->addColumn('qty', array(
139
+ 'header' => Mage::helper('sales')->__('Product Qty Ordered'),
140
+ 'index' => 'increment_id',
141
+ 'frame_callback' => array($this, 'callback_qty'),
142
+ 'filter_condition_callback' => array($this, 'filter_qty'),
143
+ ));
144
+
145
+ if (!Mage::app()->isSingleStoreMode()) {
146
+ $this->addColumn('store_id', array(
147
+ 'header' => Mage::helper('sales')->__('Purchased From (Store)'),
148
+ 'index' => 'store_id',
149
+ 'type' => 'store',
150
+ 'store_view'=> true,
151
+ 'display_deleted' => true,
152
+ ));
153
+ }
154
+
155
+ $this->addColumn('created_at', array(
156
+ 'header' => Mage::helper('sales')->__('Purchased On'),
157
+ 'index' => 'created_at',
158
+ 'type' => 'datetime',
159
+ 'width' => '100px',
160
+ ));
161
+
162
+ $this->addColumn('billing_name', array(
163
+ 'header' => Mage::helper('sales')->__('Bill to Name'),
164
+ 'index' => 'billing_name',
165
+ ));
166
+
167
+ $this->addColumn('shipping_name', array(
168
+ 'header' => Mage::helper('sales')->__('Ship to Name'),
169
+ 'index' => 'shipping_name',
170
+ ));
171
+
172
+ $this->addColumn('base_grand_total', array(
173
+ 'header' => Mage::helper('sales')->__('G.T. (Base)'),
174
+ 'index' => 'base_grand_total',
175
+ 'type' => 'currency',
176
+ 'currency' => 'base_currency_code',
177
+ ));
178
+
179
+ $this->addColumn('grand_total', array(
180
+ 'header' => Mage::helper('sales')->__('G.T. (Purchased)'),
181
+ 'index' => 'grand_total',
182
+ 'type' => 'currency',
183
+ 'currency' => 'order_currency_code',
184
+ ));
185
+
186
+ $this->addColumn('status', array(
187
+ 'header' => Mage::helper('sales')->__('Status'),
188
+ 'index' => 'status',
189
+ 'type' => 'options',
190
+ 'width' => '70px',
191
+ 'options' => Mage::getSingleton('sales/order_config')->getStatuses(),
192
+ ));
193
+
194
+ if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
195
+ $this->addColumn('action',
196
+ array(
197
+ 'header' => Mage::helper('sales')->__('Action'),
198
+ 'width' => '50px',
199
+ 'type' => 'action',
200
+ 'getter' => 'getId',
201
+ 'actions' => array(
202
+ array(
203
+ 'caption' => Mage::helper('sales')->__('View'),
204
+ 'url' => array('base'=>'*/sales_order/view'),
205
+ 'field' => 'order_id',
206
+ 'data-column' => 'action',
207
+ )
208
+ ),
209
+ 'filter' => false,
210
+ 'sortable' => false,
211
+ 'index' => 'stores',
212
+ 'is_system' => true,
213
+ ));
214
+ }
215
+ $this->addRssList('rss/order/new', Mage::helper('sales')->__('New Order RSS'));
216
+
217
+ $this->addExportType('*/*/exportCsv', Mage::helper('sales')->__('CSV'));
218
+ $this->addExportType('*/*/exportExcel', Mage::helper('sales')->__('Excel XML'));
219
+
220
+ return parent::_prepareColumns();
221
+ }
222
+
223
+ protected function _prepareMassaction()
224
+ {
225
+ $this->setMassactionIdField('entity_id');
226
+ $this->getMassactionBlock()->setFormFieldName('order_ids');
227
+ $this->getMassactionBlock()->setUseSelectAll(false);
228
+
229
+ if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/cancel')) {
230
+ $this->getMassactionBlock()->addItem('cancel_order', array(
231
+ 'label'=> Mage::helper('sales')->__('Cancel'),
232
+ 'url' => $this->getUrl('*/sales_order/massCancel'),
233
+ ));
234
+ }
235
+
236
+ if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/hold')) {
237
+ $this->getMassactionBlock()->addItem('hold_order', array(
238
+ 'label'=> Mage::helper('sales')->__('Hold'),
239
+ 'url' => $this->getUrl('*/sales_order/massHold'),
240
+ ));
241
+ }
242
+
243
+ if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/unhold')) {
244
+ $this->getMassactionBlock()->addItem('unhold_order', array(
245
+ 'label'=> Mage::helper('sales')->__('Unhold'),
246
+ 'url' => $this->getUrl('*/sales_order/massUnhold'),
247
+ ));
248
+ }
249
+
250
+ $this->getMassactionBlock()->addItem('pdfinvoices_order', array(
251
+ 'label'=> Mage::helper('sales')->__('Print Invoices'),
252
+ 'url' => $this->getUrl('*/sales_order/pdfinvoices'),
253
+ ));
254
+
255
+ $this->getMassactionBlock()->addItem('pdfshipments_order', array(
256
+ 'label'=> Mage::helper('sales')->__('Print Packingslips'),
257
+ 'url' => $this->getUrl('*/sales_order/pdfshipments'),
258
+ ));
259
+
260
+ $this->getMassactionBlock()->addItem('pdfcreditmemos_order', array(
261
+ 'label'=> Mage::helper('sales')->__('Print Credit Memos'),
262
+ 'url' => $this->getUrl('*/sales_order/pdfcreditmemos'),
263
+ ));
264
+
265
+ $this->getMassactionBlock()->addItem('pdfdocs_order', array(
266
+ 'label'=> Mage::helper('sales')->__('Print All'),
267
+ 'url' => $this->getUrl('*/sales_order/pdfdocs'),
268
+ ));
269
+
270
+ $this->getMassactionBlock()->addItem('print_shipping_label', array(
271
+ 'label'=> Mage::helper('sales')->__('Print Shipping Labels'),
272
+ 'url' => $this->getUrl('*/sales_order_shipment/massPrintShippingLabel'),
273
+ ));
274
+
275
+ return $this;
276
+ }
277
+
278
+ public function getRowUrl($row)
279
+ {
280
+ if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
281
+ return $this->getUrl('*/sales_order/view', array('order_id' => $row->getId()));
282
+ }
283
+ return false;
284
+ }
285
+
286
+ public function getGridUrl()
287
+ {
288
+ return $this->getUrl('*/*/grid', array('_current'=>true));
289
+ }
290
+
291
+ }
app/code/local/Vp/Ordersku/Helper/Data.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+ class Vp_Ordersku_Helper_Data extends Mage_Core_Helper_Abstract
3
+ {
4
+ }
5
+
app/code/local/Vp/Ordersku/etc/config.xml ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Vp_Ordersku>
5
+ <version>1.0.0</version>
6
+ </Vp_Ordersku>
7
+ </modules>
8
+ <global>
9
+ <helpers>
10
+ <ordersku>
11
+ <class>Vp_Ordersku_Helper</class>
12
+ </ordersku>
13
+ </helpers>
14
+ <blocks>
15
+ <ordersku>
16
+ <class>Vp_Ordersku_Block</class>
17
+ </ordersku>
18
+ <adminhtml>
19
+ <rewrite>
20
+ <sales_order_grid>Vp_Ordersku_Block_Adminhtml_Sales_Order_Grid</sales_order_grid>
21
+ </rewrite>
22
+ </adminhtml>
23
+ </blocks>
24
+ </global>
25
+ <admin>
26
+ <routers>
27
+ <adminhtml>
28
+ <args>
29
+ <modules>
30
+ <Vp_Ordersku before="Mage_Adminhtml">Vp_Ordersku_Adminhtml</Vp_Ordersku>
31
+ </modules>
32
+ </args>
33
+ </adminhtml>
34
+ </routers>
35
+ </admin>
36
+ </config>
app/etc/modules/Vp_Ordersku.xml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Vp_Ordersku>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ <version>1.0.0</version>
8
+ </Vp_Ordersku>
9
+ </modules>
10
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Vp_Ordersku</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license>OSL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Extends order grid - add skus n products</summary>
10
+ <description>This extension extend the order grid and display the skus and products for particular orders in order grid. </description>
11
+ <notes>Extends order grid - add skus n products</notes>
12
+ <authors><author><name>vpinfo</name><user>vpinfo39</user><email>vpinfo39@gmail.com</email></author></authors>
13
+ <date>2014-06-21</date>
14
+ <time>10:04:30</time>
15
+ <contents><target name="magelocal"><dir name="Vp"><dir name="Ordersku"><dir name="Block"><dir name="Adminhtml"><dir name="Sales"><dir name="Order"><file name="Grid.php" hash="95bc1d930b381ad8683aa82a5712e087"/></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="a60b50168d49458655bffb993b057245"/></dir><dir name="etc"><file name="config.xml" hash="03d90c2cc02d0679a413e99c804e53b8"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Vp_Ordersku.xml" hash="75ee79df6d36a3e9e00096795b022ab7"/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>