Overview

Packages

  • currencysymbol
  • MAbout
  • Mage
    • Admin
    • Adminhtml
    • AdminNotification
    • Api
    • Api2
    • Authorizenet
    • Backup
    • Bundle
    • Captcha
    • Catalog
    • CatalogIndex
    • CatalogInventory
    • CatalogRule
    • CatalogSearch
    • Centinel
    • Checkout
    • Cms
    • Compiler
    • Connect
    • Contacts
    • Core
    • Cron
    • CurrencySymbol
    • Customer
    • Dataflow
    • Directory
    • DirtectPost
    • Downloadable
    • Eav
    • GiftMessage
    • GoogleAnalytics
    • GoogleBase
    • GoogleCheckout
    • ImportExport
    • Index
    • Install
    • Log
    • Media
    • Newsletter
    • Oauth
    • Page
    • PageCache
    • Paygate
    • Payment
    • Paypal
    • PaypalUk
    • Persistent
    • Poll
    • ProductAlert
    • Rating
    • Reports
    • Review
    • Rss
    • Rule
    • Sales
    • SalesRule
    • Sedfriend
    • Sendfriend
    • Shipping
    • Sitemap
    • Tag
    • Tax
    • Usa
    • Weee
    • Widget
    • Wishlist
    • XmlConnect
  • None
  • Phoenix
    • Moneybookers
  • PHP
  • Zend
    • Date
    • Mime
    • XmlRpc

Classes

  • Mage_Reports_Block_Product_Abstract
  • Mage_Reports_Block_Product_Compared
  • Mage_Reports_Block_Product_Viewed
  • Mage_Reports_Block_Product_Widget_Compared
  • Mage_Reports_Block_Product_Widget_Viewed
  • Mage_Reports_Exception
  • Mage_Reports_Helper_Data
  • Mage_Reports_Model_Config
  • Mage_Reports_Model_Event
  • Mage_Reports_Model_Event_Observer
  • Mage_Reports_Model_Event_Type
  • Mage_Reports_Model_Flag
  • Mage_Reports_Model_Grouped_Collection
  • Mage_Reports_Model_Mysql4_Accounts_Collection
  • Mage_Reports_Model_Mysql4_Coupons_Collection
  • Mage_Reports_Model_Mysql4_Customer_Collection
  • Mage_Reports_Model_Mysql4_Customer_Orders_Collection
  • Mage_Reports_Model_Mysql4_Customer_Totals_Collection
  • Mage_Reports_Model_Mysql4_Entity_Summary_Collection_Abstract
  • Mage_Reports_Model_Mysql4_Event
  • Mage_Reports_Model_Mysql4_Event_Collection
  • Mage_Reports_Model_Mysql4_Event_Type
  • Mage_Reports_Model_Mysql4_Event_Type_Collection
  • Mage_Reports_Model_Mysql4_Invoiced_Collection
  • Mage_Reports_Model_Mysql4_Order_Collection
  • Mage_Reports_Model_Mysql4_Product_Collection
  • Mage_Reports_Model_Mysql4_Product_Downloads_Collection
  • Mage_Reports_Model_Mysql4_Product_Index_Abstract
  • Mage_Reports_Model_Mysql4_Product_Index_Collection_Abstract
  • Mage_Reports_Model_Mysql4_Product_Index_Compared
  • Mage_Reports_Model_Mysql4_Product_Index_Compared_Collection
  • Mage_Reports_Model_Mysql4_Product_Index_Viewed
  • Mage_Reports_Model_Mysql4_Product_Index_Viewed_Collection
  • Mage_Reports_Model_Mysql4_Product_Lowstock_Collection
  • Mage_Reports_Model_Mysql4_Product_Ordered_Collection
  • Mage_Reports_Model_Mysql4_Product_Sold_Collection
  • Mage_Reports_Model_Mysql4_Product_Viewed_Collection
  • Mage_Reports_Model_Mysql4_Quote_Collection
  • Mage_Reports_Model_Mysql4_Refunded_Collection
  • Mage_Reports_Model_Mysql4_Report_Abstract
  • Mage_Reports_Model_Mysql4_Report_Collection
  • Mage_Reports_Model_Mysql4_Review_Collection
  • Mage_Reports_Model_Mysql4_Review_Customer_Collection
  • Mage_Reports_Model_Mysql4_Review_Product_Collection
  • Mage_Reports_Model_Mysql4_Shipping_Collection
  • Mage_Reports_Model_Mysql4_Tag_Collection
  • Mage_Reports_Model_Mysql4_Tag_Customer_Collection
  • Mage_Reports_Model_Mysql4_Tag_Product_Collection
  • Mage_Reports_Model_Mysql4_Tax_Collection
  • Mage_Reports_Model_Mysql4_Wishlist_Collection
  • Mage_Reports_Model_Mysql4_Wishlist_Product_Collection
  • Mage_Reports_Model_Product_Index_Abstract
  • Mage_Reports_Model_Product_Index_Compared
  • Mage_Reports_Model_Product_Index_Viewed
  • Mage_Reports_Model_Report
  • Mage_Reports_Model_Resource_Accounts_Collection
  • Mage_Reports_Model_Resource_Coupons_Collection
  • Mage_Reports_Model_Resource_Customer_Collection
  • Mage_Reports_Model_Resource_Customer_Orders_Collection
  • Mage_Reports_Model_Resource_Customer_Totals_Collection
  • Mage_Reports_Model_Resource_Entity_Summary_Collection_Abstract
  • Mage_Reports_Model_Resource_Event
  • Mage_Reports_Model_Resource_Event_Collection
  • Mage_Reports_Model_Resource_Event_Type
  • Mage_Reports_Model_Resource_Event_Type_Collection
  • Mage_Reports_Model_Resource_Helper_Mysql4
  • Mage_Reports_Model_Resource_Invoiced_Collection
  • Mage_Reports_Model_Resource_Order_Collection
  • Mage_Reports_Model_Resource_Product_Collection
  • Mage_Reports_Model_Resource_Product_Downloads_Collection
  • Mage_Reports_Model_Resource_Product_Index_Abstract
  • Mage_Reports_Model_Resource_Product_Index_Collection_Abstract
  • Mage_Reports_Model_Resource_Product_Index_Compared
  • Mage_Reports_Model_Resource_Product_Index_Compared_Collection
  • Mage_Reports_Model_Resource_Product_Index_Viewed
  • Mage_Reports_Model_Resource_Product_Index_Viewed_Collection
  • Mage_Reports_Model_Resource_Product_Lowstock_Collection
  • Mage_Reports_Model_Resource_Product_Ordered_Collection
  • Mage_Reports_Model_Resource_Product_Sold_Collection
  • Mage_Reports_Model_Resource_Product_Viewed_Collection
  • Mage_Reports_Model_Resource_Quote_Collection
  • Mage_Reports_Model_Resource_Refunded_Collection
  • Mage_Reports_Model_Resource_Report_Abstract
  • Mage_Reports_Model_Resource_Report_Collection
  • Mage_Reports_Model_Resource_Report_Collection_Abstract
  • Mage_Reports_Model_Resource_Report_Product_Viewed
  • Mage_Reports_Model_Resource_Report_Product_Viewed_Collection
  • Mage_Reports_Model_Resource_Review_Collection
  • Mage_Reports_Model_Resource_Review_Customer_Collection
  • Mage_Reports_Model_Resource_Review_Product_Collection
  • Mage_Reports_Model_Resource_Shipping_Collection
  • Mage_Reports_Model_Resource_Shopcart_Product_Collection
  • Mage_Reports_Model_Resource_Tag_Collection
  • Mage_Reports_Model_Resource_Tag_Customer_Collection
  • Mage_Reports_Model_Resource_Tag_Product_Collection
  • Mage_Reports_Model_Resource_Tax_Collection
  • Mage_Reports_Model_Resource_Wishlist_Collection
  • Mage_Reports_Model_Resource_Wishlist_Product_Collection
  • Mage_Reports_Model_Session
  • Mage_Reports_Model_Test
  • Mage_Reports_Model_Totals

Interfaces

  • Mage_Reports_Model_Resource_Helper_Interface
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Magento
  4:  *
  5:  * NOTICE OF LICENSE
  6:  *
  7:  * This source file is subject to the Open Software License (OSL 3.0)
  8:  * that is bundled with this package in the file LICENSE.txt.
  9:  * It is also available through the world-wide-web at this URL:
 10:  * http://opensource.org/licenses/osl-3.0.php
 11:  * If you did not receive a copy of the license and are unable to
 12:  * obtain it through the world-wide-web, please send an email
 13:  * to license@magentocommerce.com so we can send you a copy immediately.
 14:  *
 15:  * DISCLAIMER
 16:  *
 17:  * Do not edit or add to this file if you wish to upgrade Magento to newer
 18:  * versions in the future. If you wish to customize Magento for your
 19:  * needs please refer to http://www.magentocommerce.com for more information.
 20:  *
 21:  * @category    Mage
 22:  * @package     Mage_Reports
 23:  * @copyright   Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
 24:  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 25:  */
 26: 
 27: 
 28: /**
 29:  * Coupons Report collection
 30:  *
 31:  * @category    Mage
 32:  * @package     Mage_Reports
 33:  * @author      Magento Core Team <core@magentocommerce.com>
 34:  */
 35: class Mage_Reports_Model_Resource_Coupons_Collection extends Mage_Sales_Model_Entity_Order_Collection
 36: {
 37:     /**
 38:      * From value
 39:      *
 40:      * @var string
 41:      */
 42:     protected $_from     = '';
 43: 
 44:     /**
 45:      * To value
 46:      *
 47:      * @var string
 48:      */
 49:     protected $_to       = '';
 50: 
 51:     /**
 52:      * Set date range
 53:      *
 54:      * @param string $from
 55:      * @param string $to
 56:      * @return Mage_Reports_Model_Resource_Coupons_Collection
 57:      */
 58:     public function setDateRange($from, $to)
 59:     {
 60:         $this->_from = $from;
 61:         $this->_to   = $to;
 62:         $this->_reset();
 63:         return $this;
 64:     }
 65: 
 66:     /**
 67:      * Set store ids
 68:      *
 69:      * @param array $storeIds
 70:      * @return Mage_Reports_Model_Resource_Coupons_Collection
 71:      */
 72:     public function setStoreIds($storeIds)
 73:     {
 74:         $this->joinFields($this->_from, $this->_to, $storeIds);
 75:         return $this;
 76:     }
 77: 
 78:     /**
 79:      * Join fields
 80:      *
 81:      * @param string $from
 82:      * @param string $to
 83:      * @param array $storeIds
 84:      */
 85:     public function joinFields($from, $to, $storeIds = array())
 86:     {
 87:         $this->groupByAttribute('coupon_code')
 88:             ->addAttributeToFilter('created_at', array('from' => $from, 'to' => $to, 'datetime' => true))
 89:             ->addAttributeToFilter('coupon_code', array('neq' => ''))
 90:             ->getSelect()->columns(array('uses' => 'COUNT(e.entity_id)'))
 91:             ->having('uses > ?', 0)
 92:             ->order('uses ' . self::SORT_ORDER_DESC);
 93: 
 94:         $storeIds = array_values($storeIds);
 95:         if (count($storeIds) >= 1 && $storeIds[0] != '') {
 96:             $this->addAttributeToFilter('store_id', array('in' => $storeIds));
 97:             $this->addExpressionAttributeToSelect(
 98:                 'subtotal',
 99:                 'SUM({{base_subtotal}})',
100:                 array('base_subtotal'))
101:             ->addExpressionAttributeToSelect(
102:                 'discount',
103:                 'SUM({{base_discount_amount}})',
104:                 array('base_discount_amount'))
105:             ->addExpressionAttributeToSelect(
106:                 'total',
107:                 'SUM({{base_subtotal}}-{{base_discount_amount}})',
108:                 array('base_subtotal', 'base_discount_amount'));
109:         } else {
110:             $this->addExpressionAttributeToSelect(
111:                 'subtotal',
112:                 'SUM({{base_subtotal}}*{{base_to_global_rate}})',
113:                 array('base_subtotal', 'base_to_global_rate'))
114:             ->addExpressionAttributeToSelect(
115:                 'discount',
116:                 'SUM({{base_discount_amount}}*{{base_to_global_rate}})',
117:                 array('base_discount_amount', 'base_to_global_rate'))
118:             ->addExpressionAttributeToSelect(
119:                 'total',
120:                 'SUM(({{base_subtotal}}-{{base_discount_amount}})*{{base_to_global_rate}})',
121:                 array('base_subtotal', 'base_discount_amount', 'base_to_global_rate'));
122:         }
123: 
124:     }
125: 
126:     /**
127:      * Get select count sql
128:      *
129:      * @return string
130:      */
131:     public function getSelectCountSql()
132:     {
133:         $countSelect = clone $this->getSelect();
134:         $countSelect->reset(Zend_Db_Select::ORDER);
135:         $countSelect->reset(Zend_Db_Select::LIMIT_COUNT);
136:         $countSelect->reset(Zend_Db_Select::LIMIT_OFFSET);
137:         $countSelect->reset(Zend_Db_Select::COLUMNS);
138:         $countSelect->reset(Zend_Db_Select::GROUP);
139:         $countSelect->reset(Zend_Db_Select::HAVING);
140:         $countSelect->columns('COUNT(DISTINCT main_table.rule_id)');
141: 
142:         return $countSelect;
143:     }
144: }
145: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0