2014-12-07 66 views
0

我想添加來自'sales_flat_order_status_history'表的最新評論。排序信息DESC裏面joinLeft在網格magento

$collection->getSelect()->joinLeft('sales_flat_order_status_history', 
'main_table.entity_id = sales_flat_order_status_history.parent_id', 
array('comment'=> new Zend_Db_Expr(
'(SELECT group_concat(`sales_flat_order_status_history`.comment SEPARATOR ",") 
FROM `sales_flat_order_status_history` As `sales_flat_order_status_history` 
WHERE `main_table`.`entity_id` = `sales_flat_order_status_history`.`parent_id`)'))); 

但它不工作。有人可以幫我嗎?

回答

0

的努力之後幾天,我已經找到了答案:

$collection->getSelect()->joinLeft(' 
sales_flat_order_status_history', 'main_table.entity_id = 
sales_flat_order_status_history.parent_id',array(' 
comment'=> new Zend_Db_Expr('(
SELECT `sales_flat_order_status_history`.comment 
FROM `sales_flat_order_status_history` 
As `sales_flat_order_status_history` 
WHERE `main_table`.`entity_id` = `sales_flat_order_status_history`.`parent_id` 
ORDER BY `sales_flat_order_status_history`.entity_id DESC LIMIT 0,1)'))); 

可能這將是爲別人

有用