2012-01-09 125 views
1

我有一個擴展 - 高級自定義選項。 我想在訂單/網格中顯示每個產品的相關選項。MAGENTO自定義選項網格

這是我使用的代碼:

protected function _prepareCollection() 
{ 
$collection = Mage::getResourceModel('sales/order_grid_collection'); 

$collection->getSelect()->join 
(
'sales_flat_order_item', 
'sales_flat_order_item.order_id = main_table.entity_id', 
array 
(
'price' => new Zend_Db_Expr('group_concat(sales_flat_order_item.price SEPARATOR "<br><br><hr>")'), 
'proname' => new Zend_Db_Expr('group_concat(sales_flat_order_item.name SEPARATOR "<br><hr>")'), 
'proptions' => new Zend_Db_Expr('group_concat(sales_flat_order_item.product_options SEPARATOR "<br><hr>")'), 
) 
    ); 

    $collection->getSelect()->group('main_table.entity_id'); 
    $this->setCollection($collection); 

    return Mage_Adminhtml_Block_Widget_Grid::_prepareCollection(); 
} 

結果我得到的是與產品有關的產品選項的完全數組。

我如何獲得(標題)標籤?

回答

0

您可以在return聲明上方添加以下行並給我輸出結果嗎?我有一種感覺,如果你得到了部分迴應,它可能與SQL查詢本身有關。

Mage::log($collection->getSelect()->__toString()); 

你也可以嘗試給leftJoin了一槍,而不是內部聯接使用$collection->getSelect()->leftJoin(),根據您的查詢的結構。