订单列表中的Magento类别
我想在sales grid视图中显示一些附加数据,并能够对其进行筛选 我试图为每个订单显示SKU、产品名称、总数量和产品制造商(或类别或其他属性) 有了这个代码,我就能得到前三个订单列表中的Magento类别,magento,adminhtml,Magento,Adminhtml,我想在sales grid视图中显示一些附加数据,并能够对其进行筛选 我试图为每个订单显示SKU、产品名称、总数量和产品制造商(或类别或其他属性) 有了这个代码,我就能得到前三个 $collection = Mage::getResourceModel($this->_getCollectionClass()); $collection ->join( array('s'=>'sales/order_item'), '`main_table`.entity_
$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:locality,product的一个自定义属性),我必须执行另一个join来获得产品数据,因此我认为我的代码应该类似于
$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调试(7):未能加载模板:[MYBASEDIR]/app/design/adminhtml/default/default/template/widget/grid/container.phtml
2013-10-03T14:27:00+00:00调试(7):未能加载模板:[MYBASEDIR]/app/design/adminhtml/default/default/template/page.phtml
我真的不懂。。。如何解决这个问题?如何在该集合中加入多个成员
谢谢我想你必须使用
$collection->getSelect()->加入(…)代码>而不仅仅是$collection->join(…)代码>如果您希望多次使用它。如我在文本中所述->getSelect()也尝试过,但它不起作用