我在订单项的订购部分的网格中有此列定义:
$this->addColumn('qty_ordered',
array(
'header'=> $this->__('Quantity'),
'align' =>'right',
'type=' => 'number',
'index' => 'qty_ordered'
)
);
xxx http://img688.imageshack.us/img688/6690/scr031.jpg
如何显示没有任何小数的数量?
答案 0 :(得分:2)
执行此操作的一种方法是创建自定义模块
$this->addColumn('qty_ordered',
array(
'header'=> $this->__('Quantity'),
'align' =>'right',
'type=' => 'number',
'index' => 'qty_ordered'
'renderer' = new MageIgniter_RemoveQtyDecimals_Block_Adminhtml_Renderer_Date()
)
);
class MageIgniter_RemoveQtyDecimals_Block_Adminhtml_Renderer_Date extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Action
{
public function render(Varien_Object $row)
{
return $this->_getValue($row);
}
public function _getValue(Varien_Object $row)
{
$val = $row->getData($this->getColumn()->getIndex());
return intval($val);
}
}
答案 1 :(得分:1)
我修改了sku数组定义而不是创建qty_ordered。
$collection = Mage::getResourceModel($this->_getCollectionClass())
->join(
'sales/order_item',
'`sales/order_item`.order_id=`main_table`.entity_id',
array(
'skus' => new Zend_Db_Expr('group_concat( `sales/order_item`.sku, "(", floor(`sales/order_item`.qty_ordered), ")" SEPARATOR ", ")'),
));
我相信你可以在你的qty_ordered定义中使用floor(sales/order_item
。qty_ordered)。
SKU列结果如下: MBA001(2),MOF004(1)