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_Tag_Block_All
  • Mage_Tag_Block_Customer_Recent
  • Mage_Tag_Block_Customer_Tags
  • Mage_Tag_Block_Customer_View
  • Mage_Tag_Block_Popular
  • Mage_Tag_Block_Product_List
  • Mage_Tag_Block_Product_Result
  • Mage_Tag_CustomerController
  • Mage_Tag_Helper_Data
  • Mage_Tag_IndexController
  • Mage_Tag_ListController
  • Mage_Tag_Model_Api
  • Mage_Tag_Model_Api_V2
  • Mage_Tag_Model_Entity_Customer_Collection
  • Mage_Tag_Model_Indexer_Summary
  • Mage_Tag_Model_Mysql4_Customer_Collection
  • Mage_Tag_Model_Mysql4_Indexer_Summary
  • Mage_Tag_Model_Mysql4_Popular_Collection
  • Mage_Tag_Model_Mysql4_Product_Collection
  • Mage_Tag_Model_Mysql4_Tag
  • Mage_Tag_Model_Mysql4_Tag_Collection
  • Mage_Tag_Model_Mysql4_Tag_Relation
  • Mage_Tag_Model_Resource_Customer_Collection
  • Mage_Tag_Model_Resource_Indexer_Summary
  • Mage_Tag_Model_Resource_Popular_Collection
  • Mage_Tag_Model_Resource_Product_Collection
  • Mage_Tag_Model_Resource_Tag
  • Mage_Tag_Model_Resource_Tag_Collection
  • Mage_Tag_Model_Resource_Tag_Relation
  • Mage_Tag_Model_Session
  • Mage_Tag_Model_Tag
  • Mage_Tag_Model_Tag_Relation
  • Mage_Tag_ProductController
  • 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_Tag
 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:  * Tag Indexer Model
 30:  *
 31:  * @method Mage_Tag_Model_Resource_Indexer_Summary _getResource()
 32:  * @method Mage_Tag_Model_Resource_Indexer_Summary getResource()
 33:  * @method int getTagId()
 34:  * @method Mage_Tag_Model_Indexer_Summary setTagId(int $value)
 35:  * @method int getStoreId()
 36:  * @method Mage_Tag_Model_Indexer_Summary setStoreId(int $value)
 37:  * @method int getCustomers()
 38:  * @method Mage_Tag_Model_Indexer_Summary setCustomers(int $value)
 39:  * @method int getProducts()
 40:  * @method Mage_Tag_Model_Indexer_Summary setProducts(int $value)
 41:  * @method int getUses()
 42:  * @method Mage_Tag_Model_Indexer_Summary setUses(int $value)
 43:  * @method int getHistoricalUses()
 44:  * @method Mage_Tag_Model_Indexer_Summary setHistoricalUses(int $value)
 45:  * @method int getPopularity()
 46:  * @method Mage_Tag_Model_Indexer_Summary setPopularity(int $value)
 47:  * @method int getBasePopularity()
 48:  * @method Mage_Tag_Model_Indexer_Summary setBasePopularity(int $value)
 49:  *
 50:  * @category    Mage
 51:  * @package     Mage_Tag
 52:  * @author      Magento Core Team <core@magentocommerce.com>
 53:  */
 54: class Mage_Tag_Model_Indexer_Summary extends Mage_Index_Model_Indexer_Abstract
 55: {
 56:     /**
 57:      * @var array
 58:      */
 59:     protected $_matchedEntities = array(
 60:         Mage_Catalog_Model_Product::ENTITY => array(
 61:             Mage_Index_Model_Event::TYPE_SAVE,
 62:             Mage_Index_Model_Event::TYPE_DELETE,
 63:             Mage_Index_Model_Event::TYPE_MASS_ACTION,
 64:         ),
 65:         Mage_Tag_Model_Tag::ENTITY => array(
 66:             Mage_Index_Model_Event::TYPE_SAVE
 67:         ),
 68:         Mage_Tag_Model_Tag_Relation::ENTITY => array(
 69:             Mage_Index_Model_Event::TYPE_SAVE
 70:         )
 71:     );
 72: 
 73:     /**
 74:      * Initialize resource model
 75:      *
 76:      */
 77:     protected function _construct()
 78:     {
 79:         $this->_init('tag/indexer_summary');
 80:     }
 81: 
 82:     /**
 83:      * Retrieve Indexer name
 84:      *
 85:      * @return string
 86:      */
 87:     public function getName()
 88:     {
 89:         return Mage::helper('tag')->__('Tag Aggregation Data');
 90:     }
 91: 
 92:     /**
 93:      * Retrieve Indexer description
 94:      *
 95:      * @return string
 96:      */
 97:     public function getDescription()
 98:     {
 99:         return Mage::helper('tag')->__('Rebuild Tag aggregation data');
100:     }
101: 
102:     /**
103:      * Retrieve attribute list that has an effect on tags
104:      *
105:      * @return array
106:      */
107:     protected function _getProductAttributesDependOn()
108:     {
109:         return array(
110:             'visibility',
111:             'status',
112:             'website_ids'
113:         );
114:     }
115: 
116:     /**
117:      * Register data required by process in event object
118:      *
119:      * @param Mage_Index_Model_Event $event
120:      */
121:     protected function _registerEvent(Mage_Index_Model_Event $event)
122:     {
123:         if ($event->getEntity() == Mage_Catalog_Model_Product::ENTITY) {
124:             $this->_registerCatalogProduct($event);
125:         } elseif ($event->getEntity() == Mage_Tag_Model_Tag::ENTITY) {
126:             $this->_registerTag($event);
127:         } elseif ($event->getEntity() == Mage_Tag_Model_Tag_Relation::ENTITY) {
128:             $this->_registerTagRelation($event);
129:         }
130:     }
131: 
132:     /**
133:      * Register data required by catalog product save process
134:      *
135:      * @param Mage_Index_Model_Event $event
136:      */
137:     protected function _registerCatalogProductSaveEvent(Mage_Index_Model_Event $event)
138:     {
139:         /* @var $product Mage_Catalog_Model_Product */
140:         $product = $event->getDataObject();
141:         $reindexTag = $product->getForceReindexRequired();
142: 
143:         foreach ($this->_getProductAttributesDependOn() as $attributeCode) {
144:             $reindexTag = $reindexTag || $product->dataHasChangedFor($attributeCode);
145:         }
146: 
147:         if (!$product->isObjectNew() && $reindexTag) {
148:             $event->addNewData('tag_reindex_required', true);
149:         }
150:     }
151: 
152:     /**
153:      * Register data required by catalog product delete process
154:      *
155:      * @param Mage_Index_Model_Event $event
156:      */
157:     protected function _registerCatalogProductDeleteEvent(Mage_Index_Model_Event $event)
158:     {
159:         $tagIds = Mage::getModel('tag/tag_relation')
160:             ->setProductId($event->getEntityPk())
161:             ->getRelatedTagIds();
162:         if ($tagIds) {
163:             $event->addNewData('tag_reindex_tag_ids', $tagIds);
164:         }
165:     }
166: 
167:     /**
168:      * Register data required by catalog product massaction process
169:      *
170:      * @param Mage_Index_Model_Event $event
171:      */
172:     protected function _registerCatalogProductMassActionEvent(Mage_Index_Model_Event $event)
173:     {
174:         /* @var $actionObject Varien_Object */
175:         $actionObject = $event->getDataObject();
176:         $attributes   = $this->_getProductAttributesDependOn();
177:         $reindexTags  = false;
178: 
179:         // check if attributes changed
180:         $attrData = $actionObject->getAttributesData();
181:         if (is_array($attrData)) {
182:             foreach ($attributes as $attributeCode) {
183:                 if (array_key_exists($attributeCode, $attrData)) {
184:                     $reindexTags = true;
185:                     break;
186:                 }
187:             }
188:         }
189: 
190:         // check changed websites
191:         if ($actionObject->getWebsiteIds()) {
192:             $reindexTags = true;
193:         }
194: 
195:         // register affected tags
196:         if ($reindexTags) {
197:             $tagIds = Mage::getModel('tag/tag_relation')
198:                 ->setProductId($actionObject->getProductIds())
199:                 ->getRelatedTagIds();
200:             if ($tagIds) {
201:                 $event->addNewData('tag_reindex_tag_ids', $tagIds);
202:             }
203:         }
204:     }
205: 
206:     protected function _registerCatalogProduct(Mage_Index_Model_Event $event)
207:     {
208:         switch ($event->getType()) {
209:             case Mage_Index_Model_Event::TYPE_SAVE:
210:                 $this->_registerCatalogProductSaveEvent($event);
211:                 break;
212: 
213:             case Mage_Index_Model_Event::TYPE_DELETE:
214:                 $this->_registerCatalogProductDeleteEvent($event);
215:                 break;
216: 
217:             case Mage_Index_Model_Event::TYPE_MASS_ACTION:
218:                 $this->_registerCatalogProductMassActionEvent($event);
219:                 break;
220:         }
221:     }
222: 
223:     protected function _registerTag(Mage_Index_Model_Event $event)
224:     {
225:         if ($event->getType() == Mage_Index_Model_Event::TYPE_SAVE) {
226:             $event->addNewData('tag_reindex_tag_id', $event->getEntityPk());
227:         }
228:     }
229: 
230:     protected function _registerTagRelation(Mage_Index_Model_Event $event)
231:     {
232:         if ($event->getType() == Mage_Index_Model_Event::TYPE_SAVE) {
233:             $event->addNewData('tag_reindex_tag_id', $event->getDataObject()->getTagId());
234:         }
235:     }
236: 
237:     /**
238:      * Process event
239:      *
240:      * @param Mage_Index_Model_Event $event
241:      */
242:     protected function _processEvent(Mage_Index_Model_Event $event)
243:     {
244:         $this->callEventHandler($event);
245:     }
246: }
247: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0