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:  * Report events resource model
 30:  *
 31:  * @category    Mage
 32:  * @package     Mage_Reports
 33:  * @author      Magento Core Team <core@magentocommerce.com>
 34:  */
 35: class Mage_Reports_Model_Resource_Event extends Mage_Core_Model_Resource_Db_Abstract
 36: {
 37:     /**
 38:      * Initialize main table and identifier field.
 39:      * Set main entity table name and primary key field name.
 40:      *
 41:      * @return void
 42:      */
 43:     protected function _construct()
 44:     {
 45:         $this->_init('reports/event', 'event_id');
 46:     }
 47: 
 48:     /**
 49:      * Update customer type after customer login
 50:      *
 51:      * @param Mage_Reports_Model_Event $model
 52:      * @param int $visitorId
 53:      * @param int $customerId
 54:      * @param array $types
 55:      * @return Mage_Reports_Model_Resource_Event
 56:      */
 57:     public function updateCustomerType(Mage_Reports_Model_Event $model, $visitorId, $customerId, $types = array())
 58:     {
 59:         if ($types) {
 60:             $this->_getWriteAdapter()->update($this->getMainTable(),
 61:                 array('subject_id' => (int)$customerId, 'subtype' => 0),
 62:                 array(
 63:                     'subject_id = ?'      => (int)$visitorId,
 64:                     'subtype = ?'         => 1,
 65:                     'event_type_id IN(?)' => $types
 66:                 )
 67:             );
 68:         }
 69:         return $this;
 70:     }
 71: 
 72:     /**
 73:      * Add events log to a collection
 74:      * The collection id field is used without corellation, so it must be unique.
 75:      * DESC ordering by event will be added to the collection
 76:      *
 77:      * @param Varien_Data_Collection_Db $collection
 78:      * @param int $eventTypeId
 79:      * @param int $eventSubjectId
 80:      * @param int $subtype
 81:      * @param array $skipIds
 82:      * @return Mage_Reports_Model_Resource_Event
 83:      */
 84:     public function applyLogToCollection(Varien_Data_Collection_Db $collection, $eventTypeId, $eventSubjectId, $subtype,
 85:         $skipIds = array())
 86:     {
 87:         $idFieldName = $collection->getResource()->getIdFieldName();
 88: 
 89:         $derivedSelect = $this->getReadConnection()->select()
 90:             ->from(
 91:                 $this->getTable('reports/event'),
 92:                 array('event_id' => new Zend_Db_Expr('MAX(event_id)'), 'object_id'))
 93:             ->where('event_type_id = ?', (int)$eventTypeId)
 94:             ->where('subject_id = ?', (int)$eventSubjectId)
 95:             ->where('subtype = ?', (int)$subtype)
 96:             ->where('store_id IN(?)', $this->getCurrentStoreIds())
 97:             ->group('object_id');
 98: 
 99:         if ($skipIds) {
100:             if (!is_array($skipIds)) {
101:                 $skipIds = array((int)$skipIds);
102:             }
103:             $derivedSelect->where('object_id NOT IN(?)', $skipIds);
104:         }
105: 
106:         $collection->getSelect()
107:             ->joinInner(
108:                 array('evt' => new Zend_Db_Expr("({$derivedSelect})")),
109:                 "{$idFieldName} = evt.object_id",
110:                 array())
111:             ->order('evt.event_id ' . Varien_Db_Select::SQL_DESC);
112: 
113:         return $this;
114:     }
115: 
116:     /**
117:      * Obtain all current store ids, depending on configuration
118:      *
119:      * @param array $predefinedStoreIds
120:      * @return array
121:      */
122:     public function getCurrentStoreIds(array $predefinedStoreIds = null)
123:     {
124:         $stores = array();
125:         // get all or specified stores
126:         if (Mage::app()->getStore()->getId() == 0) {
127:             if (null !== $predefinedStoreIds) {
128:                 $stores = $predefinedStoreIds;
129:             } else {
130:                 foreach (Mage::app()->getStores() as $store) {
131:                     $stores[] = $store->getId();
132:                 }
133:             }
134:         } else { // get all stores, required by configuration in current store scope
135:             switch (Mage::getStoreConfig('catalog/recently_products/scope')) {
136:                 case 'website':
137:                     $resourceStore = Mage::app()->getStore()->getWebsite()->getStores();
138:                     break;
139:                 case 'group':
140:                     $resourceStore = Mage::app()->getStore()->getGroup()->getStores();
141:                     break;
142:                 default:
143:                     $resourceStore = array(Mage::app()->getStore());
144:                     break;
145:             }
146: 
147:             foreach ($resourceStore as $store) {
148:                 $stores[] = $store->getId();
149:             }
150:         }
151:         foreach ($stores as $key => $store) {
152:             $stores[$key] = (int)$store;
153:         }
154: 
155:         return $stores;
156:     }
157: 
158:     /**
159:      * Clean report event table
160:      *
161:      * @param Mage_Reports_Model_Event $object
162:      * @return Mage_Reports_Model_Resource_Event
163:      */
164:     public function clean(Mage_Reports_Model_Event $object)
165:     {
166:         while (true) {
167:             $select = $this->_getReadAdapter()->select()
168:                 ->from(array('event_table' => $this->getMainTable()), array('event_id'))
169:                 ->joinLeft(
170:                     array('visitor_table' => $this->getTable('log/visitor')),
171:                     'event_table.subject_id = visitor_table.visitor_id',
172:                     array())
173:                 ->where('visitor_table.visitor_id IS NULL')
174:                 ->where('event_table.subtype = ?', 1)
175:                 ->limit(1000);
176:             $eventIds = $this->_getReadAdapter()->fetchCol($select);
177: 
178:             if (!$eventIds) {
179:                 break;
180:             }
181: 
182:             $this->_getWriteAdapter()->delete($this->getMainTable(), array('event_id IN(?)' => $eventIds));
183:         }
184:         return $this;
185:     }
186: }
187: 
188: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0