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.