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:  * Reports Product Index Abstract Model
 30:  *
 31:  * @category   Mage
 32:  * @package    Mage_Reports
 33:  * @author     Magento Core Team <core@magentocommerce.com>
 34:  */
 35: abstract class Mage_Reports_Model_Product_Index_Abstract extends Mage_Core_Model_Abstract
 36: {
 37:     /**
 38:      * Cache key name for Count of product index
 39:      *
 40:      * @var string
 41:      */
 42:     protected $_countCacheKey;
 43: 
 44:     /**
 45:      * Prepare customer/visitor, store data before save
 46:      *
 47:      * @return Mage_Reports_Model_Product_Index_Abstract
 48:      */
 49:     protected function _beforeSave()
 50:     {
 51:         parent::_beforeSave();
 52: 
 53:         if (!$this->hasVisitorId()) {
 54:             $this->setVisitorId($this->getVisitorId());
 55:         }
 56:         if (!$this->hasCustomerId()) {
 57:             $this->setCustomerId($this->getCustomerId());
 58:         }
 59:         if (!$this->hasStoreId()) {
 60:             $this->setStoreId($this->getStoreId());
 61:         }
 62:         if (!$this->hasAddedAt()) {
 63:             $this->setAddedAt(now());
 64:         }
 65: 
 66:         return $this;
 67:     }
 68: 
 69:     /**
 70:      * Retrieve visitor id
 71:      *
 72:      * if don't exists return current visitor id
 73:      *
 74:      * @return int
 75:      */
 76:     public function getVisitorId()
 77:     {
 78:         if ($this->hasData('visitor_id')) {
 79:             return $this->getData('visitor_id');
 80:         }
 81:         return Mage::getSingleton('log/visitor')->getId();
 82:     }
 83: 
 84:     /**
 85:      * Retrieve customer id
 86:      *
 87:      * if customer don't logged in return null
 88:      *
 89:      * @return int
 90:      */
 91:     public function getCustomerId()
 92:     {
 93:         if ($this->hasData('customer_id')) {
 94:             return $this->getData('customer_id');
 95:         }
 96:         return Mage::getSingleton('customer/session')->getCustomerId();
 97:     }
 98: 
 99:     /**
100:      * Retrieve store id
101:      *
102:      * default return current store id
103:      *
104:      * @return int
105:      */
106:     public function getStoreId()
107:     {
108:         if ($this->hasData('store_id')) {
109:             return $this->getData('store_id');
110:         }
111:         return Mage::app()->getStore()->getId();
112:     }
113: 
114:     /**
115:      * Retrieve resource instance wrapper
116:      *
117:      * @return Mage_Reports_Model_Mysql4_Product_Index_Abstract
118:      */
119:     protected function _getResource()
120:     {
121:         return parent::_getResource();
122:     }
123: 
124:     /**
125:      * On customer loggin merge visitor/customer index
126:      *
127:      * @return Mage_Reports_Model_Product_Index_Abstract
128:      */
129:     public function updateCustomerFromVisitor()
130:     {
131:         $this->_getResource()->updateCustomerFromVisitor($this);
132:         return $this;
133:     }
134: 
135:     /**
136:      * Purge visitor data by customer (logout)
137:      *
138:      * @return Mage_Reports_Model_Product_Index_Abstract
139:      */
140:     public function purgeVisitorByCustomer()
141:     {
142:         $this->_getResource()->purgeVisitorByCustomer($this);
143:         return $this;
144:     }
145: 
146:     /**
147:      * Retrieve Reports Session instance
148:      *
149:      * @return Mage_Reports_Model_Session
150:      */
151:     protected function _getSession()
152:     {
153:         return Mage::getSingleton('reports/session');
154:     }
155: 
156:     /**
157:      * Calculate count of product index items cache
158:      *
159:      * @return Mage_Reports_Model_Product_Index_Abstract
160:      */
161:     public function calculate()
162:     {
163:         $collection = $this->getCollection()
164:             ->setCustomerId($this->getCustomerId())
165:             ->addIndexFilter();
166: 
167:         Mage::getSingleton('catalog/product_visibility')
168:             ->addVisibleInSiteFilterToCollection($collection);
169: 
170:         $count = $collection->getSize();
171:         $this->_getSession()->setData($this->_countCacheKey, $count);
172:         return $this;
173:     }
174: 
175:     /**
176:      * Retrieve Exclude Product Ids List for Collection
177:      *
178:      * @return array
179:      */
180:     public function getExcludeProductIds()
181:     {
182:         return array();
183:     }
184: 
185:     /**
186:      * Retrieve count of product index items
187:      *
188:      * @return int
189:      */
190:     public function getCount()
191:     {
192:         if (!$this->_countCacheKey) {
193:             return 0;
194:         }
195: 
196:         if (!$this->_getSession()->hasData($this->_countCacheKey)) {
197:             $this->calculate();
198:         }
199: 
200:         return $this->_getSession()->getData($this->_countCacheKey);
201:     }
202: 
203:     /**
204:      * Clean index (visitors)
205:      *
206:      * @return Mage_Reports_Model_Product_Index_Abstract
207:      */
208:     public function clean()
209:     {
210:         $this->_getResource()->clean($this);
211:         return $this;
212:     }
213: 
214:     /**
215:      * Add product ids to current visitor/customer log
216:      * @param array $productIds
217:      * @return Mage_Reports_Model_Product_Index_Abstract
218:      */
219:     public function registerIds($productIds)
220:     {
221:         $this->_getResource()->registerIds($this, $productIds);
222:         $this->_getSession()->unsData($this->_countCacheKey);
223:         return $this;
224:     }
225: }
226: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0