我已将交货日期添加为产品的自定义选项。我希望交货日期显示在管理员的销售订单网格中。我已经创建了Namespace_Module_Block_Adminhtml_Sales_Order_Grid
.
在_prepareCollection()
函数中,我可以获得产品选项:
$collection = Mage::getResourceModel($this->_getCollectionClass())
->join(
'sales/order_item',
'`sales/order_item`.order_id=`main_table`.entity_id',
array(
**'proptions' => new Zend_Db_Expr('group_concat(`sales/order_item`.product_options SEPARATOR ",")'),**
)
);
然后我将列添加为:
$this->addColumn('proptions', array(
'header' => Mage::helper('Sales')->__('Product Options'),
'width' => '100px',
'index' => 'proptions',
'renderer' => new Namespace_Module_Block_Adminhtml_Renderer_Data(),
));
现在Namespace_Module_Block_Adminhtml_Renderer_Data()
我有一个方法:
public function _getValue(Varien_Object $row)
{
$val = $row->getData($this->getColumn()->getIndex()); // row value
$array = unserialize($val);
//loop thru the $array and create a format string
//
$options = $array['options'];
$format_val = '';
foreach ($options as $key=> $value) {
$format_val = $format_val . $key . "=>" . $value . " , ";
}
return $format_val;
}
显示不正确。我认为我没有正确循环数组。我在这里做错了什么?