Version Notes
Fixed error with unknown column.
Download this release
Release Info
Developer | Arron Moss |
Extension | Zero1_CustomOrderGrid |
Version | 1.0.2 |
Comparing to | |
See all releases |
Code changes from version 1.0.1 to 1.0.2
app/code/community/Zero1/CustomOrderGrid/Block/Sales/Order/Grid.php
CHANGED
@@ -1,35 +1,190 @@
|
|
1 |
<?php
|
2 |
-
class Zero1_CustomOrderGrid_Block_Sales_Order_Grid extends
|
3 |
{
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
}
|
1 |
<?php
|
2 |
+
class Zero1_CustomOrderGrid_Block_Sales_Order_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
3 |
{
|
4 |
+
public function __construct()
|
5 |
+
{
|
6 |
+
parent::__construct();
|
7 |
+
$this->setId('sales_order_grid');
|
8 |
+
$this->setUseAjax(true);
|
9 |
+
$this->setDefaultSort('created_at');
|
10 |
+
$this->setDefaultDir('DESC');
|
11 |
+
$this->setSaveParametersInSession(true);
|
12 |
+
}
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Retrieve collection class
|
16 |
+
*
|
17 |
+
* @return string
|
18 |
+
*/
|
19 |
+
protected function _getCollectionClass()
|
20 |
+
{
|
21 |
+
return 'sales/order_grid_collection';
|
22 |
+
}
|
23 |
+
|
24 |
+
protected function _prepareCollection()
|
25 |
+
{
|
26 |
+
$collection = Mage::getResourceModel($this->_getCollectionClass());
|
27 |
+
Mage::dispatchEvent('zero1_custom_order_grid_prepare_collection', array('collection' => $collection));
|
28 |
+
|
29 |
+
$this->setCollection($collection);
|
30 |
+
$x = parent::_prepareCollection();
|
31 |
+
return $x;
|
32 |
+
}
|
33 |
+
|
34 |
+
protected function _prepareColumns()
|
35 |
+
{
|
36 |
+
$this->addColumn('real_order_id', array(
|
37 |
+
'header'=> Mage::helper('sales')->__('Order #'),
|
38 |
+
'width' => '80px',
|
39 |
+
'type' => 'text',
|
40 |
+
'index' => 'increment_id',
|
41 |
+
));
|
42 |
+
|
43 |
+
if (!Mage::app()->isSingleStoreMode()) {
|
44 |
+
$this->addColumn('store_id', array(
|
45 |
+
'header' => Mage::helper('sales')->__('Purchased From (Store)'),
|
46 |
+
'index' => 'store_id',
|
47 |
+
'type' => 'store',
|
48 |
+
'store_view'=> true,
|
49 |
+
'display_deleted' => true,
|
50 |
+
));
|
51 |
+
}
|
52 |
+
|
53 |
+
$this->addColumn('created_at', array(
|
54 |
+
'header' => Mage::helper('sales')->__('Purchased On'),
|
55 |
+
'index' => 'created_at',
|
56 |
+
'type' => 'datetime',
|
57 |
+
'width' => '100px',
|
58 |
+
));
|
59 |
+
|
60 |
+
$this->addColumn('billing_name', array(
|
61 |
+
'header' => Mage::helper('sales')->__('Bill to Name'),
|
62 |
+
'index' => 'billing_name',
|
63 |
+
));
|
64 |
+
|
65 |
+
$this->addColumn('shipping_name', array(
|
66 |
+
'header' => Mage::helper('sales')->__('Ship to Name'),
|
67 |
+
'index' => 'shipping_name',
|
68 |
+
));
|
69 |
+
|
70 |
+
$this->addColumn('base_grand_total', array(
|
71 |
+
'header' => Mage::helper('sales')->__('G.T. (Base)'),
|
72 |
+
'index' => 'base_grand_total',
|
73 |
+
'type' => 'currency',
|
74 |
+
'currency' => 'base_currency_code',
|
75 |
+
));
|
76 |
+
|
77 |
+
$this->addColumn('grand_total', array(
|
78 |
+
'header' => Mage::helper('sales')->__('G.T. (Purchased)'),
|
79 |
+
'index' => 'grand_total',
|
80 |
+
'type' => 'currency',
|
81 |
+
'currency' => 'order_currency_code',
|
82 |
+
));
|
83 |
+
|
84 |
+
$this->addColumn('status', array(
|
85 |
+
'header' => Mage::helper('sales')->__('Status'),
|
86 |
+
'index' => 'status',
|
87 |
+
'type' => 'options',
|
88 |
+
'width' => '70px',
|
89 |
+
'options' => Mage::getSingleton('sales/order_config')->getStatuses(),
|
90 |
+
));
|
91 |
+
|
92 |
+
if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
|
93 |
+
$this->addColumn('action',
|
94 |
+
array(
|
95 |
+
'header' => Mage::helper('sales')->__('Action'),
|
96 |
+
'width' => '50px',
|
97 |
+
'type' => 'action',
|
98 |
+
'getter' => 'getId',
|
99 |
+
'actions' => array(
|
100 |
+
array(
|
101 |
+
'caption' => Mage::helper('sales')->__('View'),
|
102 |
+
'url' => array('base'=>'*/sales_order/view'),
|
103 |
+
'field' => 'order_id'
|
104 |
+
)
|
105 |
+
),
|
106 |
+
'filter' => false,
|
107 |
+
'sortable' => false,
|
108 |
+
'index' => 'stores',
|
109 |
+
'is_system' => true,
|
110 |
+
));
|
111 |
+
}
|
112 |
+
|
113 |
+
Mage::dispatchEvent('zero1_custom_order_grid_add_columns', array('grid' => $this));
|
114 |
+
|
115 |
+
$this->addRssList('rss/order/new', Mage::helper('sales')->__('New Order RSS'));
|
116 |
+
|
117 |
+
$this->addExportType('*/*/exportCsv', Mage::helper('sales')->__('CSV'));
|
118 |
+
$this->addExportType('*/*/exportExcel', Mage::helper('sales')->__('Excel XML'));
|
119 |
+
|
120 |
+
return parent::_prepareColumns();
|
121 |
+
}
|
122 |
+
|
123 |
+
protected function _prepareMassaction()
|
124 |
+
{
|
125 |
+
$this->setMassactionIdField('entity_id');
|
126 |
+
$this->getMassactionBlock()->setFormFieldName('order_ids');
|
127 |
+
$this->getMassactionBlock()->setUseSelectAll(false);
|
128 |
+
|
129 |
+
if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/cancel')) {
|
130 |
+
$this->getMassactionBlock()->addItem('cancel_order', array(
|
131 |
+
'label'=> Mage::helper('sales')->__('Cancel'),
|
132 |
+
'url' => $this->getUrl('*/sales_order/massCancel'),
|
133 |
+
));
|
134 |
+
}
|
135 |
+
|
136 |
+
if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/hold')) {
|
137 |
+
$this->getMassactionBlock()->addItem('hold_order', array(
|
138 |
+
'label'=> Mage::helper('sales')->__('Hold'),
|
139 |
+
'url' => $this->getUrl('*/sales_order/massHold'),
|
140 |
+
));
|
141 |
+
}
|
142 |
+
|
143 |
+
if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/unhold')) {
|
144 |
+
$this->getMassactionBlock()->addItem('unhold_order', array(
|
145 |
+
'label'=> Mage::helper('sales')->__('Unhold'),
|
146 |
+
'url' => $this->getUrl('*/sales_order/massUnhold'),
|
147 |
+
));
|
148 |
+
}
|
149 |
+
|
150 |
+
$this->getMassactionBlock()->addItem('pdfinvoices_order', array(
|
151 |
+
'label'=> Mage::helper('sales')->__('Print Invoices'),
|
152 |
+
'url' => $this->getUrl('*/sales_order/pdfinvoices'),
|
153 |
+
));
|
154 |
+
|
155 |
+
$this->getMassactionBlock()->addItem('pdfshipments_order', array(
|
156 |
+
'label'=> Mage::helper('sales')->__('Print Packingslips'),
|
157 |
+
'url' => $this->getUrl('*/sales_order/pdfshipments'),
|
158 |
+
));
|
159 |
+
|
160 |
+
$this->getMassactionBlock()->addItem('pdfcreditmemos_order', array(
|
161 |
+
'label'=> Mage::helper('sales')->__('Print Credit Memos'),
|
162 |
+
'url' => $this->getUrl('*/sales_order/pdfcreditmemos'),
|
163 |
+
));
|
164 |
+
|
165 |
+
$this->getMassactionBlock()->addItem('pdfdocs_order', array(
|
166 |
+
'label'=> Mage::helper('sales')->__('Print All'),
|
167 |
+
'url' => $this->getUrl('*/sales_order/pdfdocs'),
|
168 |
+
));
|
169 |
+
|
170 |
+
$this->getMassactionBlock()->addItem('print_shipping_label', array(
|
171 |
+
'label'=> Mage::helper('sales')->__('Print Shipping Labels'),
|
172 |
+
'url' => $this->getUrl('*/sales_order_shipment/massPrintShippingLabel'),
|
173 |
+
));
|
174 |
+
|
175 |
+
return $this;
|
176 |
+
}
|
177 |
+
|
178 |
+
public function getRowUrl($row)
|
179 |
+
{
|
180 |
+
if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
|
181 |
+
return $this->getUrl('*/sales_order/view', array('order_id' => $row->getId()));
|
182 |
+
}
|
183 |
+
return false;
|
184 |
+
}
|
185 |
+
|
186 |
+
public function getGridUrl()
|
187 |
+
{
|
188 |
+
return $this->getUrl('*/*/grid', array('_current'=>true));
|
189 |
+
}
|
190 |
}
|
app/code/community/Zero1/CustomOrderGrid/Model/Observer.php
CHANGED
@@ -1,33 +1,62 @@
|
|
1 |
<?php
|
2 |
class Zero1_CustomOrderGrid_Model_Observer
|
3 |
{
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
}
|
1 |
<?php
|
2 |
class Zero1_CustomOrderGrid_Model_Observer
|
3 |
{
|
4 |
+
public function zero1CustomOrderGridAddColumns(Varien_Event_Observer $observer){
|
5 |
+
/* @var $grid Zero1_CustomOrderGrid_Block_Sales_Order_Grid */
|
6 |
+
$grid = $observer->getEvent()->getGrid();
|
7 |
+
|
8 |
+
// Add the selected columns if they are enabled
|
9 |
+
$enabled_options = Mage::getStoreConfig('zero1_customordergrid/options/columns_to_show');
|
10 |
+
$enabled_options = explode(',', $enabled_options);
|
11 |
+
|
12 |
+
if(in_array('products_ordered', $enabled_options)) {
|
13 |
+
$grid->addColumnAfter('products_ordered', array(
|
14 |
+
'header' => Mage::helper('sales')->__('Products Ordered'),
|
15 |
+
'index' => 'products_ordered',
|
16 |
+
'renderer' => 'zero1_customordergrid/sales_order_grid_renderer_product',
|
17 |
+
'type' => 'textarea',
|
18 |
+
'width' => '500px',
|
19 |
+
), 'status');
|
20 |
+
}
|
21 |
+
|
22 |
+
if(in_array('customer_email', $enabled_options)) {
|
23 |
+
$grid->addColumnAfter('customer_email', array(
|
24 |
+
'header' => Mage::helper('sales')->__('Customer Email'),
|
25 |
+
'index' => 'customer_email',
|
26 |
+
'type' => 'textarea',
|
27 |
+
), 'status');
|
28 |
+
}
|
29 |
+
}
|
30 |
+
|
31 |
+
public function zero1CustomOrderGridPrepareCollection(Varien_Event_Observer $observer){
|
32 |
+
/* @var $collection Mage_Sales_Model_Resource_Order_Grid_Collection */
|
33 |
+
$collection = $observer->getEvent()->getCollection();
|
34 |
+
$select = $collection->getSelect();
|
35 |
+
|
36 |
+
// Add the selected columns if they are enabled
|
37 |
+
$enabled_options = Mage::getStoreConfig('zero1_customordergrid/options/columns_to_show');
|
38 |
+
$enabled_options = explode(',', $enabled_options);
|
39 |
+
|
40 |
+
if(in_array('products_ordered', $enabled_options)) {
|
41 |
+
$table_sales_flat_order_item = Mage::getSingleton('core/resource')->getTableName('sales/order_item');
|
42 |
+
$collection->addFilterToMap('products_ordered', $table_sales_flat_order_item.'.products_ordered');
|
43 |
+
$select->joinLeft(
|
44 |
+
$table_sales_flat_order_item,
|
45 |
+
'main_table.entity_id = '.$table_sales_flat_order_item.'.order_id',
|
46 |
+
array('products_ordered' => 'GROUP_CONCAT(ROUND(qty_ordered), " x ", name, " (", sku, ")" SEPARATOR "'.PHP_EOL.'")')
|
47 |
+
);
|
48 |
+
$select->group('main_table.entity_id');
|
49 |
+
}
|
50 |
+
|
51 |
+
if(in_array('customer_email', $enabled_options)) {
|
52 |
+
$table_sales_flat_order = Mage::getSingleton('core/resource')->getTableName('sales/order');
|
53 |
+
$collection->addFilterToMap('customer_email', $table_sales_flat_order.'.customer_email');
|
54 |
+
|
55 |
+
$select->joinLeft(
|
56 |
+
$table_sales_flat_order,
|
57 |
+
'main_table.entity_id = '.$table_sales_flat_order.'.entity_id',
|
58 |
+
array('customer_email AS customer_email')
|
59 |
+
);
|
60 |
+
}
|
61 |
+
}
|
62 |
}
|
app/code/community/Zero1/CustomOrderGrid/etc/config.xml
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Zero1_CustomOrderGrid>
|
5 |
-
<version>1.0.
|
6 |
</Zero1_CustomOrderGrid>
|
7 |
</modules>
|
8 |
<global>
|
@@ -30,15 +30,24 @@
|
|
30 |
</zero1_customordergrid_setup>
|
31 |
</resources>
|
32 |
<events>
|
33 |
-
<
|
34 |
<observers>
|
35 |
<zero1_customordergrid>
|
36 |
<type>model</type>
|
37 |
<class>zero1_customordergrid/observer</class>
|
38 |
-
<method>
|
39 |
</zero1_customordergrid>
|
40 |
</observers>
|
41 |
-
</
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
</events>
|
43 |
</global>
|
44 |
<adminhtml>
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Zero1_CustomOrderGrid>
|
5 |
+
<version>1.0.2</version>
|
6 |
</Zero1_CustomOrderGrid>
|
7 |
</modules>
|
8 |
<global>
|
30 |
</zero1_customordergrid_setup>
|
31 |
</resources>
|
32 |
<events>
|
33 |
+
<zero1_custom_order_grid_add_columns>
|
34 |
<observers>
|
35 |
<zero1_customordergrid>
|
36 |
<type>model</type>
|
37 |
<class>zero1_customordergrid/observer</class>
|
38 |
+
<method>zero1CustomOrderGridAddColumns</method>
|
39 |
</zero1_customordergrid>
|
40 |
</observers>
|
41 |
+
</zero1_custom_order_grid_add_columns>
|
42 |
+
<zero1_custom_order_grid_prepare_collection>
|
43 |
+
<observers>
|
44 |
+
<zero1_customordergrid>
|
45 |
+
<type>model</type>
|
46 |
+
<class>zero1_customordergrid/observer</class>
|
47 |
+
<method>zero1CustomOrderGridPrepareCollection</method>
|
48 |
+
</zero1_customordergrid>
|
49 |
+
</observers>
|
50 |
+
</zero1_custom_order_grid_prepare_collection>
|
51 |
</events>
|
52 |
</global>
|
53 |
<adminhtml>
|
app/etc/modules/Zero1_CustomOrderGrid.xml
CHANGED
@@ -4,6 +4,17 @@
|
|
4 |
<Zero1_CustomOrderGrid>
|
5 |
<active>true</active>
|
6 |
<codePool>community</codePool>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
</Zero1_CustomOrderGrid>
|
8 |
</modules>
|
9 |
-
</config>
|
4 |
<Zero1_CustomOrderGrid>
|
5 |
<active>true</active>
|
6 |
<codePool>community</codePool>
|
7 |
+
<!--
|
8 |
+
<depends>
|
9 |
+
http://stackoverflow.com/questions/12610949/magento-module-layout-xml-load-order
|
10 |
+
|
11 |
+
<Enterprise_GiftCardAccount/>
|
12 |
+
<Enterprise_Staging/>
|
13 |
+
<Mage_Captcha/>
|
14 |
+
<Mage_XmlConnect/>
|
15 |
+
<Enterprise_Reminder/>
|
16 |
+
|
17 |
+
</depends>-->
|
18 |
</Zero1_CustomOrderGrid>
|
19 |
</modules>
|
20 |
+
</config>
|
package.xml
CHANGED
@@ -1,18 +1,18 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Zero1_CustomOrderGrid</name>
|
4 |
-
<version>1.0.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://shop.zero1.co.uk/LICENSE.txt">Commercial</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
-
<summary>
|
10 |
-
<description>
|
11 |
-
<notes>Fixed
|
12 |
<authors><author><name>Arron Moss</name><user>zero1limited</user><email>arron.moss@zero1.co.uk</email></author></authors>
|
13 |
-
<date>
|
14 |
-
<time>
|
15 |
-
<contents><target name="magecommunity"><dir name="Zero1"><dir name="CustomOrderGrid"><dir name="Block"><dir name="Sales"><dir name="Order"><dir name="Grid"><dir name="Renderer"><file name="Product.php" hash="2bc72bfca53e7b1dd868d9866d57c58d"/></dir></dir><file name="Grid.php" hash="
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Zero1_CustomOrderGrid</name>
|
4 |
+
<version>1.0.2</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://shop.zero1.co.uk/LICENSE.txt">Commercial</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
+
<summary>Add custom columns to sales order gird.</summary>
|
10 |
+
<description>Add custom columns to sales order gird.</description>
|
11 |
+
<notes>Fixed error with unknown column.</notes>
|
12 |
<authors><author><name>Arron Moss</name><user>zero1limited</user><email>arron.moss@zero1.co.uk</email></author></authors>
|
13 |
+
<date>2015-01-06</date>
|
14 |
+
<time>09:01:55</time>
|
15 |
+
<contents><target name="magecommunity"><dir name="Zero1"><dir name="CustomOrderGrid"><dir name="Block"><dir name="Sales"><dir name="Order"><dir name="Grid"><dir name="Renderer"><file name="Product.php" hash="2bc72bfca53e7b1dd868d9866d57c58d"/></dir></dir><file name="Grid.php" hash="32acadc2cb0c3554932805cdb84a9452"/></dir><file name="Order.php" hash="2fa73a7f9527969e06a8399b1e574e76"/></dir></dir><dir name="Helper"><file name="Data.php" hash="b13e271f2c77300eff69c62efbd93eb0"/></dir><dir name="Model"><file name="Observer.php" hash="1c8e7bb8928bb498e17cc11480d9f6d5"/><dir name="Source"><file name="Fields.php" hash="48b894a075b59bee4954f32188e4f574"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="c70a0d687271000fe0c0d55a703bf65f"/><file name="config.xml" hash="1da16fd918889ccb000476335590b144"/><file name="system.xml" hash="c05ded0c4d35fa61dc1f6ef1d834cbd3"/></dir><dir name="sql"><dir name="zero1_customordergrid_setup"><file name="mysql4-install-0.1.0.php" hash="8fe5d704f8524628b85e438052d54324"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Zero1_CustomOrderGrid.xml" hash="c3b6429ecedb6831c5a54e8195a53098"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><dir name="zero1"><file name="customordergrid.xml" hash="bfeb216a6489c319fdf1de5ed1ce6a30"/></dir></dir></dir></dir></dir></target></contents>
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
</package>
|