00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 class Mage_Reports_Model_Mysql4_Shipping_Collection extends Mage_Sales_Model_Entity_Order_Collection
00036 {
00037
00038 public function setDateRange($from, $to)
00039 {
00040 $this->_reset()
00041 ->addAttributeToSelect('*')
00042 ->addAttributeToFilter('created_at', array('from' => $from, 'to' => $to))
00043 ->addExpressionAttributeToSelect('orders', 'COUNT(DISTINCT({{entity_id}}))', array('entity_id'))
00044 ->addAttributeToSelect('shipping_description')
00045 ->groupByAttribute('shipping_description')
00046 ->getSelect()->order('orders desc');
00047
00048 $this->getSelect()->where("`_table_shipping_description`.`value` <> ''");
00049 return $this;
00050 }
00051
00052 public function setStoreIds($storeIds)
00053 {
00054 $vals = array_values($storeIds);
00055 if (count($storeIds) >= 1 && $vals[0] != '') {
00056 $this->addAttributeToFilter('store_id', array('in' => (array)$storeIds));
00057 $this->addExpressionAttributeToSelect('total',
00058 'SUM({{base_shipping_amount}})',
00059 array('base_shipping_amount'));
00060 } else {
00061 $this->addExpressionAttributeToSelect('total',
00062 'SUM({{base_shipping_amount}}*{{base_to_global_rate}})',
00063 array('base_shipping_amount', 'base_to_global_rate'));
00064 }
00065
00066 return $this;
00067 }
00068 }