从另外两个现有列 magento 产品销售报告中添加总计列

Add a total column from two other existed column magento product sold report

我正在处理 magento 产品销售报告。目前,我有 2 个存在的列,它们是价格和 ordered_quantity。我想添加一个名为 "total cost" 的列,它等于价格 * ordered_quantity。但我不知道怎么办。这是我的代码。 请帮忙!

$this->addColumn('ordered_qty', array(
     'header'    =>Mage::helper('reports')->__('Quantity Ordered'),
     'width'     =>'120px',
     'align'     =>'right',
     'index'     =>'ordered_qty',
     'total'     =>'sum',
     'type'      =>'number'
));
//Unit price column
$this->addColumn('price', array(
     'header'    =>Mage::helper('reports')->__('Unit Price'),
     'width'     =>'200px',
     'index'     =>'price',
     'align'     =>'right'
));
//Total money column
$this->addColumn('total', array(
     'header'    =>Mage::helper('reports')->__('Total'),
     'width'     =>'200px',
     'index'     => 'total',//This returns null
     'total'     =>'sum',
     'align'     =>'right',
     'type'      =>'number'
));

我找到了答案。使用渲染自定义可以完美地工作。 这是我的代码。

public function render(Varien_Object $row)
      {                                  
          $price = $row->getPrice();
          $orderedQty=$row->getOrderedQty();         
          $total = $price * $orderedQty;
          return $total;
      }