我为magento安装了一个脚本。它允许在订单上添加注释。所以它在订单网格上显示了一条评论。
问题是它没有按“created_at”列对评论进行排序。我不知道如何设置订单。
这是代码的一部分:
protected function _initSelect()
{
parent::_initSelect();
// Join order comment
$this->getSelect()->joinLeft(
array('ordercomment_table' => $this->getTable('sales/order_status_history')),
'main_table.entity_id = ordercomment_table.parent_id AND ordercomment_table.comment IS NOT NULL',
array(
'ordercomment' => 'ordercomment_table.comment',
)
)->group('main_table.entity_id');
return $this;
}
感谢您的帮助。
答案 0 :(得分:5)
protected function _initSelect()
{
parent::_initSelect();
// Join order comment
$this->getSelect()->joinLeft(
array('ordercomment_table' => $this->getTable('sales/order_status_history')),
'main_table.entity_id = ordercomment_table.parent_id AND ordercomment_table.comment IS NOT NULL',
array(
'ordercomment' => 'ordercomment_table.comment',
)
)->group('main_table.entity_id');
//Add ORDER BY
$this->getSelect()->order(array('ordercomment_table.created_at DESC'));
return $this;
}
答案 1 :(得分:0)
在上面的现有功能中替换此行。添加ORDER BY。
$this->getSelect()->order('ordercomment_table.created_at', 'DESC');