Step 1 :- Copy app\code\core\Mage\Adminhtml\Block\Sales\Order\grid.php
to
app\code\local\Mage\Adminhtml\Block\Sales\Order\grid.php now Find _prepareColumns() function to Add column use this code:-
$this->addColumn('color ', array( 'header' => Mage::helper('sales')->__('color #'), 'index' => 'color', 'sortable' => false, 'filter' => false, 'renderer' => 'Mage_Adminhtml_Block_Sales_Order_Renderer_Productatt', ));Step 2:- Create a new file at :-
app\code\local\Mage\Adminhtml\Block\Sales\Order\Renderer\Productatt.php add this code :-
<?php class Mage_Adminhtml_Block_Sales_Order_Renderer_Productatt extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract { public function render(Varien_Object $row) { $order = Mage::getModel('sales/order')->load($row->getData('entity_id')); $attribute =""; foreach($order->getAllVisibleItems() as $_item){ $product = Mage::getModel('catalog/product')->load($_item->getProductId()); if($product->getAttributeText('color')){ $attribute .= $product->getAttributeText('color'); } } unset($order); return $attribute; } } ?>
No comments:
Post a Comment