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:  * Visitor log collection
 30:  *
 31:  * @category    Mage
 32:  * @package     Mage_Log
 33:  * @author      Magento Core Team <core@magentocommerce.com>
 34:  */
 35: 
 36: class Mage_Log_Model_Resource_Visitor_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
 37: {
 38:     /**
 39:      * Visitor data table name
 40:      *
 41:      * @var string
 42:      */
 43:     protected $_visitorTable;
 44: 
 45:     /**
 46:      * Visitor data info table name
 47:      *
 48:      * @var string
 49:      */
 50:     protected $_visitorInfoTable;
 51: 
 52:     /**
 53:      * Customer data table
 54:      *
 55:      * @var string
 56:      */
 57:     protected $_customerTable;
 58: 
 59:     /**
 60:      * Log URL data table name.
 61:      *
 62:      * @var string
 63:      */
 64:     protected $_urlTable;
 65: 
 66:     /**
 67:      * Log URL expanded data table name.
 68:      *
 69:      * @var string
 70:      */
 71:     protected $_urlInfoTable;
 72: 
 73:     /**
 74:      * Aggregator data table.
 75:      *
 76:      * @var string
 77:      */
 78:     protected $_summaryTable;
 79: 
 80:     /**
 81:      * Aggregator type data table.
 82:      *
 83:      * @var string
 84:      */
 85:     protected $_summaryTypeTable;
 86: 
 87:     /**
 88:      * Quote data table.
 89:      *
 90:      * @var string
 91:      */
 92:     protected $_quoteTable;
 93: 
 94:     /**
 95:      * Online filter used flag
 96:      * 
 97:      * @var bool
 98:      */
 99:     protected $_isOnlineFilterUsed = false;
100: 
101:     /**
102:      * Field map
103:      *
104:      * @var array
105:      */
106:     protected $_fieldMap = array(
107:         'customer_firstname' => 'customer_firstname_table.value',
108:         'customer_lastname'  => 'customer_lastname_table.value',
109:         'customer_email'     => 'customer_email_table.email',
110:         'customer_id'        => 'customer_table.customer_id',
111:         'url'                => 'url_info_table.url'
112:     );
113: 
114:     /**
115:      * Collection resource initialization
116:      */
117:     protected function _construct()
118:     {
119:         $this->_init('log/visitor');
120: 
121:         $this->_visitorTable     = $this->getTable('log/visitor');
122:         $this->_visitorInfoTable = $this->getTable('log/visitor_info');
123:         $this->_urlTable         = $this->getTable('log/url_table');
124:         $this->_urlInfoTable     = $this->getTable('log/url_info_table');
125:         $this->_customerTable    = $this->getTable('log/customer');
126:         $this->_summaryTable     = $this->getTable('log/summary_table');
127:         $this->_summaryTypeTable = $this->getTable('log/summary_type_table');
128:         $this->_quoteTable       = $this->getTable('log/quote_table');
129:     }
130: 
131:     /**
132:      * Filter for customers only
133:      *
134:      * @return Mage_Log_Model_Resource_Visitor_Collection
135:      */
136:     public function showCustomersOnly()
137:     {
138:         $this->getSelect()
139:             ->where('customer_table.customer_id > 0')
140:             ->group('customer_table.customer_id');
141:         
142:         return $this;
143:     }
144: 
145:     /**
146:      * Get GROUP BY date format
147:      *
148:      * @deprecated since 1.5.0.0
149:      * @param string $type
150:      * @return string
151:      */
152:     protected function _getGroupByDateFormat($type)
153:     {
154:         switch ($type) {
155:             case 'day':
156:                 $format = '%Y-%m-%d';
157:                 break;
158:             default:
159:             case 'hour':
160:                 $format = '%Y-%m-%d %H';
161:                 break;
162:         }
163:         return $format;
164:     }
165: 
166:     /**
167:      * Get range by type
168:      *
169:      * @deprecated since 1.5.0.0
170:      * @param string $typeCode
171:      * @return string
172:      */
173:     protected function _getRangeByType($typeCode)
174:     {
175:         switch ($typeCode)
176:         {
177:             case 'day':
178:                 $range = 'DAY';
179:                 break;
180:             case 'hour':
181:                 $range = 'HOUR';
182:                 break;
183:             case 'minute':
184:             default:
185:                 $range = 'MINUTE';
186:                 break;
187: 
188:         }
189: 
190:         return $range;
191:     }
192: 
193:     /**
194:      * Filter by customer ID, as 'type' field does not exist
195:      *
196:      * @param string $fieldName
197:      * @param array $condition
198:      * @return Mage_Log_Model_Resource_Visitor_Collection
199:      */
200:     public function addFieldToFilter($fieldName, $condition = null)
201:     {
202:         if ($fieldName == 'type' && is_array($condition) && isset($condition['eq'])) {
203:             $fieldName = 'customer_id';
204:             if ($condition['eq'] === Mage_Log_Model_Visitor::VISITOR_TYPE_VISITOR) {
205:                 $condition = array('null' => 1);
206:             } else {
207:                 $condition = array('moreq' => 1);
208:             }
209:         }
210:         return parent::addFieldToFilter($this->_getFieldMap($fieldName), $condition);
211:     }
212: 
213:     /**
214:      * Return field with table prefix
215:      *
216:      * @param string $fieldName
217:      * @return string
218:      */
219:     protected function _getFieldMap($fieldName)
220:     {
221:         if(isset($this->_fieldMap[$fieldName])) {
222:             return $this->_fieldMap[$fieldName];
223:         } else {
224:             return 'main_table.' . $fieldName;
225:         }
226:     }
227: 
228:     /**
229:      * Load data
230:      *
231:      * @param boolean $printQuery
232:      * @param boolean $logQuery
233:      * @return Mage_Core_Model_Resource_Db_Collection_Abstract
234:      */
235:     public function load($printQuery = false, $logQuery = false)
236:     {
237:         if ($this->isLoaded()) {
238:             return $this;
239:         }
240:         Mage::dispatchEvent('log_visitor_collection_load_before', array('collection' => $this));
241:         return parent::load($printQuery, $logQuery);
242:     }
243: 
244:     /**
245:      * Return true if online filter used
246:      *
247:      * @return boolean
248:      */
249:     public function getIsOnlineFilterUsed()
250:     {
251:         return $this->_isOnlineFilterUsed;
252:     }
253: 
254:     /**
255:      * Filter visitors by specified store ids
256:      *
257:      * @param array|int $storeIds
258:      */
259:     public function addVisitorStoreFilter($storeIds)
260:     {
261:         $this->getSelect()->where('visitor_table.store_id IN (?)', $storeIds);
262:     }
263: }
264: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0