我已將交貨日期添加爲產品的自定義選項。我希望將交貨日期顯示在管理員的銷售訂單網格中。 我已經創建了Namespace_Module_Block_Adminhtml_Sales_Order_Grid的本地副本。在這裏,在_prepareCollection()函數,我能夠獲得產品選項:將產品自定義選項的交貨日期添加到magento中的銷售訂單網格
$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;
}
顯示不正確。我沒有正確地循環訪問數組。有人能指導我做什麼,我在這裏做錯了嗎?
謝謝, 尼特
嗨,這個問題似乎是因爲查詢返回的值不完整: – neetw