-1
In meiner benutzerdefinierten Grid habe ich Liste Ländercode, Gesamtauftrag und bestellte Menge. ich nicht immer total_order, wie ich es in mysql Abfrage aber nicht in dem Raster Ergebnis bin immer, überprüfen Sie bitte unten Code für Grid und Sammlung: In der Sammlung:Kundenauftrag nach Land in Admin
protected function _addAddressFields()
{
$shippingAliasName = 'shipping_o_a';
$joinTable = $this->getTable('sales/order_address');
$this->addFilterToMap('shipping_country_id', $shippingAliasName . '.country_id');
$this
->getSelect()
->join(
array($shippingAliasName => $joinTable),
"(main_table.entity_id = {$shippingAliasName}.parent_id)",
array(
$shippingAliasName . '.country_id'
)
)
->columns(array('totals' => 'count(main_table.entity_id)'))
->group($shippingAliasName.'.country_id');
Mage::getResourceHelper('core')->prepareColumnsList($this->getSelect());
echo $this->getSelect();exit;
return $this;
}
Im Grid:
protected function _prepareColumns()
{
$this->addColumn('country', array(
'header' =>Mage::helper('reports')->__('Country Code'),
'index' =>'country_id'
));
$this->addColumn('total_orders', array(
'header' =>Mage::helper('reports')->__('Orders'),
'index' =>'totals'
));
$this->addColumn('ordered_qty', array(
'header' =>Mage::helper('reports')->__('Quantity Ordered'),
'width' =>'120px',
'align' =>'right',
'index' =>'entity_id',
'total' =>'count',
'type' =>'number'
));
//$this->addExportType('*/*/exportSoldCsv', Mage::helper('reports')->__('CSV'));
//$this->addExportType('*/*/exportSoldExcel', Mage::helper('reports')->__('Excel XML'));
return parent::_prepareColumns();
}