For a Magento website, I would like to show custom options in the orders grid in the backoffice.
Currently, I've successfully added a custom column to the grid with the help of this guide and this guide, using a module to avoid to rewrite the core classes.
Now, I've a long string appearing in a column and I would like to serialize it to have the custom options, but I can't manage to use a custom renderer.
/app/code/local/Atwix/ExtendedGrid/Helper/Data.php :
public function getProductOptionsColumnParams()
{
return array(
'header' => 'Products Options',
'index' => 'product_options',
'type' => 'text',
'renderer' => array('Atwix_ExtendedGrid_Model_Observer', 'render'),
);
}
I've added a renderer which links to the Model Observer (/app/code/local/Atwix/ExtendedGrid/Model/Observer.php), but this doesn't work, it only shows a white page instead of the table...
Where did I do a mistake ? The "render" function cannot be in the Observer ? I tried to create a class which extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract in /app/code/local/Mage/Adminhtml/Block/Sales/Order (near to Grid.php) but it doesn't work either.
UPDATE 1 :
It doesn't work, I've created the file /app/code/local/Atwix/ExtendedGrid/Block/Adminhtml/ExtendedGrid/Renderer/Renderer.php
with the code :
class Atwix_ExtendedGrid_Block_Product extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
{
public function render(Varien_Object $row) {
$value = $row->getData($this->getColumn()->getIndex());
return '<span style="color:red;">'.$value.'</span>';
}
}
And in /app/code/local/Atwix/ExtendedGrid/Helper/Data.php I have this code :
class Atwix_ExtendedGrid_Helper_Data extends Mage_Core_Helper_Abstract
{
/**
* parameters for addColumnAfter method
* @return array
*/
public function getSkusColumnParams()
{
return array(
'header' => 'SKUs',
'index' => 'skus',
'type' => 'text',
'filter_condition_callback' => array('Atwix_ExtendedGrid_Model_Observer', 'filterSkus'),
);
}
/**
* parameters for addColumnAfter method
* @return array
*/
public function getProductOptionsColumnParams()
{
return array(
'header' => 'Products Options',
'index' => 'product_options',
'type' => 'text',
'renderer' => array('Atwix_ExtendedGrid_Block_Product', 'render'),
);
}
}