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_Log_Helper_Data
  • Mage_Log_Model_Aggregation
  • Mage_Log_Model_Cron
  • Mage_Log_Model_Customer
  • Mage_Log_Model_Log
  • Mage_Log_Model_Mysql4_Aggregation
  • Mage_Log_Model_Mysql4_Customer
  • Mage_Log_Model_Mysql4_Log
  • Mage_Log_Model_Mysql4_Visitor
  • Mage_Log_Model_Mysql4_Visitor_Collection
  • Mage_Log_Model_Mysql4_Visitor_Online
  • Mage_Log_Model_Mysql4_Visitor_Online_Collection
  • Mage_Log_Model_Resource_Aggregation
  • Mage_Log_Model_Resource_Customer
  • Mage_Log_Model_Resource_Log
  • Mage_Log_Model_Resource_Visitor
  • Mage_Log_Model_Resource_Visitor_Collection
  • Mage_Log_Model_Resource_Visitor_Online
  • Mage_Log_Model_Resource_Visitor_Online_Collection
  • Mage_Log_Model_Visitor
  • Mage_Log_Model_Visitor_Online
  • 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_Log
 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:  * Log aggregation resource model 
 30:  *
 31:  * @category    Mage
 32:  * @package     Mage_Log
 33:  * @author      Magento Core Team <core@magentocommerce.com>
 34:  */
 35: class Mage_Log_Model_Resource_Aggregation extends Mage_Core_Model_Resource_Db_Abstract
 36: {
 37:     /**
 38:      * Resource initialization
 39:      *
 40:      */
 41:     protected function _construct()
 42:     {
 43:         $this->_init('log/summary_table', 'log_summary_id');
 44:     }
 45: 
 46:     /**
 47:      * Retrieve last added record
 48:      *
 49:      * @return string
 50:      */
 51:     public function getLastRecordDate()
 52:     {
 53:         $adapter    = $this->_getReadAdapter();
 54:         $select     = $adapter->select()
 55:             ->from($this->getTable('log/summary_table'),
 56:                 array($adapter->quoteIdentifier('date')=>'MAX(add_date)'));
 57: 
 58:         return $adapter->fetchOne($select);
 59:     }
 60: 
 61:     /**
 62:      * Retrieve count of visitors, customers
 63:      *
 64:      * @param string $from
 65:      * @param string $to
 66:      * @param int $store
 67:      * @return array
 68:      */
 69:     public function getCounts($from, $to, $store)
 70:     {
 71:         $adapter    = $this->_getReadAdapter();
 72:         $result     = array('customers'=>0, 'visitors'=>0);
 73:         $select     = $adapter->select()
 74:             ->from($this->getTable('log/customer'), 'visitor_id')
 75:             ->where('login_at >= ?', $from)
 76:             ->where('login_at <= ?', $to);
 77:         if ($store) {
 78:             $select->where('store_id = ?', $store);
 79:         }
 80: 
 81:         $customers = $adapter->fetchCol($select);
 82:         $result['customers'] = count($customers);
 83: 
 84: 
 85:         $select = $adapter->select();
 86:         $select->from($this->getTable('log/visitor'), 'COUNT(*)')
 87:             ->where('first_visit_at >= ?', $from)
 88:             ->where('first_visit_at <= ?', $to);
 89: 
 90:         if ($store) {
 91:             $select->where('store_id = ?', $store);
 92:         }
 93:         if ($result['customers']) {
 94:             $select->where('visitor_id NOT IN(?)', $customers);
 95:         }
 96: 
 97:         $result['visitors'] = $adapter->fetchOne($select);
 98: 
 99: 
100:         return $result;
101:     }
102: 
103:     /**
104:      * Save log
105:      *
106:      * @param array $data
107:      * @param int $id
108:      */
109:     public function saveLog($data, $id = null)
110:     {
111:         $adapter = $this->_getWriteAdapter();
112:         if (is_null($id)) {
113:             $adapter->insert($this->getTable('log/summary_table'), $data);
114:         } else {
115:             $condition = $adapter->quoteInto('summary_id = ?', $id);
116:             $adapter->update($this->getTable('log/summary_table'), $data, $condition);
117:         }
118:     }
119: 
120:     /**
121:      * Remove empty records
122:      *
123:      * @param string $date
124:      */
125:     public function removeEmpty($date)
126:     {
127:         $adapter    = $this->_getWriteAdapter();
128:         $condition  = array(
129:             'add_date < ?' => $date,
130:             'customer_count = 0',
131:             'visitor_count = 0'
132:         ); 
133:         $adapter->delete($this->getTable('log/summary_table'), $condition);
134:     }
135: 
136:     /**
137:      * Retrieve log id
138:      *
139:      * @param string $from
140:      * @param string $to
141:      * @return string
142:      */
143:     public function getLogId($from, $to)
144:     {
145:         $adapter    = $this->_getReadAdapter();
146:         $select     = $adapter->select()
147:             ->from($this->getTable('log/summary_table'), 'summary_id')
148:             ->where('add_date >= ?', $from)
149:             ->where('add_date <= ?', $to);
150: 
151:         return $adapter->fetchOne($select);
152:     }
153: }
154: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0