Edit the grid.phtml file located:
.../app/design/adminhtml/default/default/template/widget/grid.phtml
At line 81-87:
<select name="<?php echo $this->getVarNameLimit() ?>” onchange="<?php echo $this->getId() ?>JsObject.loadByElement(this)">
<option value="20"<?php if($this->getCollection()->getPageSize()==20): ?> selected="selected"<?php endif; ?>>20</option>
<option value="30"<?php if($this->getCollection()->getPageSize()==30): ?> selected="selected"<?php endif; ?>>30</option>
<option value="50"<?php if($this->getCollection()->getPageSize()==50): ?> selected="selected"<?php endif; ?>>50</option>
<option value="100"<?php if($this->getCollection()->getPageSize()==100): ?> selected="selected"<?php endif; ?>>100</option>
<option value="200"<?php if($this->getCollection()->getPageSize()==200): ?> selected="selected"<?php endif; ?>>200</option>
</select>
Changing the above to the below for example:
<select name="<?php echo $this->getVarNameLimit() ?>” onchange="<?php echo $this->getId() ?>JsObject.loadByElement(this)">
<option value="200"<?php if($this->getCollection()->getPageSize()==200): ?> selected="selected"<?php endif; ?>>200</option>
<option value="300"<?php if($this->getCollection()->getPageSize()==300): ?> selected="selected"<?php endif; ?>>300</option>
<option value="500"<?php if($this->getCollection()->getPageSize()==500): ?> selected="selected"<?php endif; ?>>500</option>
<option value="1000"<?php if($this->getCollection()->getPageSize()==1000): ?> selected="selected"<?php endif; ?>>1000</option>
<option value="2000"<?php if($this->getCollection()->getPageSize()==2000): ?> selected="selected"<?php endif; ?>>2000</option>
</select>
Hope this helps?
You're in the right place to start your investigation at app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php
. A look at _prepareColumns()
indicates the renderer for that column:
protected function _prepareColumns()
{
//snip...
if (!Mage::app()->isSingleStoreMode()) {
$this->addColumn('store_id', array(
'header' => Mage::helper('sales')->__('Purchased From (Store)'),
'index' => 'store_id',
'type' => 'store',
'store_view'=> true,
'display_deleted' => true,
));
}
//snip...
}
The type
will result in this column being rendered by the Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Store::render()
method:
public function render(Varien_Object $row)
{
$out = '';
$skipAllStoresLabel = $this->_getShowAllStoresLabelFlag();
$skipEmptyStoresLabel = $this->_getShowEmptyStoresLabelFlag();
$origStores = $row->getData($this->getColumn()->getIndex());
if (is_null($origStores) && $row->getStoreName()) {
$scopes = array();
foreach (explode("\n", $row->getStoreName()) as $k => $label) {
$scopes[] = str_repeat(' ', $k * 3) . $label;
}
$out .= implode('<br/>', $scopes) . $this->__(' [deleted]');
return $out;
}
if (empty($origStores) && !$skipEmptyStoresLabel) {
return '';
}
if (!is_array($origStores)) {
$origStores = array($origStores);
}
if (empty($origStores)) {
return '';
}
elseif (in_array(0, $origStores) && count($origStores) == 1 && !$skipAllStoresLabel) {
return Mage::helper('adminhtml')->__('All Store Views');
}
$data = $this->_getStoreModel()->getStoresStructure(false, $origStores);
foreach ($data as $website) {
$out .= $website['label'] . '<br/>';
foreach ($website['children'] as $group) {
$out .= str_repeat(' ', 3) . $group['label'] . '<br/>';
foreach ($group['children'] as $store) {
$out .= str_repeat(' ', 6) . $store['label'] . '<br/>';
}
}
}
return $out;
}
What a terrible method! At most, block classes should handle view logic and prepare the data for rendering in a template context. Here we see an inflexible mix of logic and markup. Therefore you have two options to customize this:
- rewrite this method with the output marked up the way you like, or
- rewrite the grid class to change the renderer type being used.
Either case could be justified. Option #1 is the most direct, but it is likely to impact other views which use this same render. If that's what you want universally then go for it. For the latter you would declare a custom module block class group, rewrite the sales order grid class, and point to your custom renderer in the type
parameter.
You are not alone in asking that eBay/Magento make this more flexible. There is a hackathon project which made grids configurable in XML, and Magento 2 has this listed as a feature.
Best Answer
Actually the piece of code does not create the order grid. This retrieves the ordered items for an order. It's used both in frontend and backend.
If you modify it to sort by sku then the items will be ordered by sku in the backend and frontend.
In order to do this you need to add this piece of code:
Right after
Of course, don't edit the code. Override the model properly.
But I wouldn't recommend this approach. If you want the order of items by sku only in the backend you could sort them in the template.
The template is
app\design\adminhtml\default\default\template\sales\order\view\items.phtml
. You can replace the code that renders the items (I mean this):With this:
Again...don't modify the template. Put it in your own theme and modify it there.
Here is how you can change and admin theme.