大家好我想在销售订单网格中添加一列,以显示exp:color产品的自定义属性 非常感谢你的帮助。
答案 0 :(得分:1)
步骤1: - 复制app \ code \ core \ Mage \ Adminhtml \ Block \ Sales \ Order \ grid.php 至 应用程序\代码\本地\法师\ Adminhtml \块\销售\订单\ grid.php 查找受保护的函数_prepareColumns() 要添加列,请使用以下代码: -
$this->addColumn('color ', array(
'header' => Mage::helper('sales')->__('color #'),
'index' => 'color',
'sortable' => false,
'filter' => false,
'renderer' => 'Mage_Adminhtml_Block_Sales_Order_Renderer_Productatt',
));
步骤2: - 在以下位置创建新文件: -
应用\代码\本地\法师\ Adminhtml \块\ SALES \订单\渲染\ Productatt.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; } }