我想表明在銷售網格視圖一些額外的數據,並能在其上過濾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加入該集合...?
感謝
正如文中所述我也試過 - > getSelect(),但它不起作用 – SimoneB