Grid 将交货日期从产品自定义选项添加到magento中的销售订单网格中
我在产品上添加了交货日期作为自定义选项。我希望交货日期显示在管理中的销售订单网格中。 我已经创建了Grid 将交货日期从产品自定义选项添加到magento中的销售订单网格中,grid,magento-1.7,ecommerce-sales,Grid,Magento 1.7,Ecommerce Sales,我在产品上添加了交货日期作为自定义选项。我希望交货日期显示在管理中的销售订单网格中。 我已经创建了名称空间\模块\块\管理HTML \销售\订单\网格的本地副本 在\u prepareCollection()函数中,我可以获得以下产品选项: $collection = Mage::getResourceModel($this->_getCollectionClass()) ->join( 'sales/order_item', '`sales/order_it
名称空间\模块\块\管理HTML \销售\订单\网格的本地副本
在\u 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\u Module\u Block\u Adminhtml\u Renderer\u 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;
}
显示不正确。我认为我没有正确地在数组中循环。我做错了什么 通过更新MySQL解决:
设置会话组\u concat\u max\u len=1000000
这也可以在全局级别设置。
谢谢
Neet如果您想在直接sql任务中执行此操作,请打开此文件。->app->design->adminhtml->default->default->template->your template->info.phtml并添加此代码
<div class="entry-edit">
<div class="entry-edit-head">
<h4 class="icon-head head-products"><?php echo Mage::helper('sales')->__('Delivery Time Information') ?></h4>
</div>
</div>
<div class="grid np">
$connection = Mage::getSingleton('core/resource')->getConnection('core_read');
//$write = Mage::getSingleton('core/resource')->getConnection('core_write');//for writing to database
$sql = "SELECT * FROM tablename";
$results = $connection->fetchAll($sql);
foreach($results as $result) {
echo $result['column_name']."<br/>";
}
</div></div></div>
$connection=Mage::getSingleton('core/resource')->getConnection('core_read');
//$write=Mage::getSingleton('core/resource')->getConnection('core_write')//用于写入数据库
$sql=“从表名中选择*”;
$results=$connection->fetchAll($sql);
foreach($results作为$result){
echo$result['column_name']。“
”;
}
hi,问题似乎是因为查询返回的值不完整: