2012-01-09 128 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(),根据您的查询的结构。