How to insert a personal note or text area on order grid page for each order, This should save when entered the text. is that possible using Renderer. If there is any module for this please suggest, or some code hints would be helpful.
Magento 1.9 Order Grid – Add Textarea in Order Grid View
magento-1.9order-gridrenderer
Related Solutions
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.
I recently build a module in which i could generate some pdf quotation also by selecting customers and products. I came across the following documentation which might be usefull to you. This uses magento product selector widget to add lines to you own module. I think its what your looking for. I haven't tested it yet but i am adding it to my module. Maybe it can be your solution. Let me know how it works if youre going to try it.
http://andreitara.com/2012/02/using-magento-product-chooser-widget-in-youre-own-module/
Best Answer
Create a custom module*
Then create a custom render:
after wards extend the Block / rewrite the Grid and add your column:
No its time to update the config.xml and add a custom layout:
add your layout file in
app/design/adminhtml/default/default/layout/namespace.xml
:finally create the layout file
app/design/adminhtml/default/default/template/namespace/modulename/inline-edit.phtml
and add updateNote in your backend controller: