2013-10-03 68 views
0

我想表明在销售网格视图一些额外的数据,并能在其上过滤Magento的类别列表订单

我试图展现每种产品的SKU,产品名称,总数量和产品制造商(或类别或其他属性)

有了这个代码,我能拿到前三

$collection = Mage::getResourceModel($this->_getCollectionClass()); 
$collection 
    ->join(
    array('s'=>'sales/order_item'), 
    '`main_table`.entity_id=s.order_id', 
    array(
    'skus' => new Zend_Db_Expr('group_concat(s.sku SEPARATOR ", ")'), 
    'names' => new Zend_Db_Expr('group_concat(s.name SEPARATOR ", ")'), 
    'items' => new Zend_Db_Expr('count(s.qty_ordered)'), 
    ) 
    ); 
$collection->getSelect()->group('entity_id'); 

而且它的工作原理:)

要获得附加数据(ES:位置,产品的自定义属性),我已经做另一加入以获得产品数据,所以我想我的代码应该是类似的东西

$collection = Mage::getResourceModel($this->_getCollectionClass()); 
$collection 
    ->join(
    array('s'=>'sales/order_item'), 
    '`main_table`.entity_id=s.order_id', 
    array(
    'skus' => new Zend_Db_Expr('group_concat(s.sku SEPARATOR ", ")'), 
    'names' => new Zend_Db_Expr('group_concat(s.name SEPARATOR ", ")'), 
    'items' => new Zend_Db_Expr('count(s.qty_ordered)'), 
    ) 
    ); 
$collection //OR $collection->getSelect() both don't work 
    ->join(
    array('p'=>'catalog/product'), 
    'p.entity_id=s.product_id', 
    array(
     ..... 
    ) 
    ); 

.... more stuff 

$collection->getSelect()->group('entity_id'); 

但每一次我尝试添加第二次加入我在日志中收到模板o_O错误

2013-10-03T14:27:00 + 00:00 DEBUG(7):无法加载模板:[MYBASEDIR]/app/design/adminhtml/default/default /template/widget/grid/container.phtml

2013-10-03T14:27:00 + 00:00 DEBUG(7):无法加载模板:[MYBASEDIR]/app/design/adminhtml/default/default /template/page.phtml

我真的很无能......如何解决这个问题?如何做超过1加入该集合...?

感谢

回答

0

我想你,如果你想使用它不止一次使用$collection->getSelect()->join(..);,而不仅仅是$collection->join(...);

+0

正如文中所述我也试过 - > getSelect(),但它不起作用 – SimoneB