Mage_CatalogIndex_Model_Observer Class Reference

Inheritance diagram for Mage_CatalogIndex_Model_Observer:

Mage_Core_Model_Abstract Varien_Object

List of all members.

Public Member Functions

 reindexAll ()
 reindexDaily ()
 processAfterSaveEvent (Varien_Event_Observer $observer)
 processPriceScopeChange (Varien_Event_Observer $observer)
 processPriceRuleApplication (Varien_Event_Observer $observer)
 processAfterDeleteEvent (Varien_Event_Observer $observer)
 processAttributeChangeEvent (Varien_Event_Observer $observer)
 processStoreAdd (Varien_Event_Observer $observer)
 catalogProductImportAfter (Varien_Event_Observer $observer)
 runQueuedIndexing ()
 cleanCache (Varien_Event_Observer $observer)
 catalogCategorySaveAfter (Varien_Event_Observer $observer)
 clearPriceAggregation ()
 clearSearchLayerCache ()
 registerParentIds (Varien_Event_Observer $observer)
 processProductsWebsitesChange (Varien_Event_Observer $observer)
 catalogProductFlatPrepareColumns (Varien_Event_Observer $observer)
 catalogProductFlatPrepareIndexes (Varien_Event_Observer $observer)
 catalogProductFlatRebuild (Varien_Event_Observer $observer)
 catalogProductFlatUpdateProduct (Varien_Event_Observer $observer)

Protected Member Functions

 _construct ()
 _getIndexer ()
 _getAggregator ()

Protected Attributes

 $_parentProductIds = array()
 $_productIdsMassupdate = array()


Detailed Description

Event observer and indexer running application

Author:
Magento Core Team <core@magentocommerce.com>

Definition at line 33 of file Observer.php.


Member Function Documentation

_construct (  )  [protected]

Enter description here...

Reimplemented from Varien_Object.

Definition at line 38 of file Observer.php.

00038 {}

_getAggregator (  )  [protected]

Get aggregation object

Returns:
Mage_CatalogIndex_Model_Aggregation

Definition at line 55 of file Observer.php.

00056     {
00057         return Mage::getSingleton('catalogindex/aggregation');
00058     }

_getIndexer (  )  [protected]

Get indexer object

Returns:
Mage_CatalogIndex_Model_Indexer

Definition at line 45 of file Observer.php.

00046     {
00047         return Mage::getSingleton('catalogindex/indexer');
00048     }

catalogCategorySaveAfter ( Varien_Event_Observer observer  ) 

Process index data after category save

Parameters:
Varien_Event_Observer $observer
Returns:
Mage_CatalogIndex_Model_Observer

Definition at line 269 of file Observer.php.

00270     {
00271         $category = $observer->getEvent()->getCategory();
00272         $tags = array(
00273             Mage_Catalog_Model_Category::CACHE_TAG.':'.$category->getPath()
00274         );
00275         $this->_getAggregator()->clearCacheData($tags);
00276         return $this;
00277     }

catalogProductFlatPrepareColumns ( Varien_Event_Observer observer  ) 

Prepare columns for catalog product flat

Parameters:
Varien_Event_Observer $observer
Returns:
Mage_CatalogIndex_Model_Observer

Definition at line 341 of file Observer.php.

00342     {
00343         $columns = $observer->getEvent()->getColumns();
00344 
00345         $this->_getIndexer()->prepareCatalogProductFlatColumns($columns);
00346 
00347         return $this;
00348     }

catalogProductFlatPrepareIndexes ( Varien_Event_Observer observer  ) 

Prepare indexes for catalog product flat

Parameters:
Varien_Event_Observer $observer
Returns:
Mage_CatalogIndex_Model_Observer

Definition at line 356 of file Observer.php.

00357     {
00358         $indexes = $observer->getEvent()->getIndexes();
00359 
00360         $this->_getIndexer()->prepareCatalogProductFlatIndexes($indexes);
00361 
00362         return $this;
00363     }

catalogProductFlatRebuild ( Varien_Event_Observer observer  ) 

Rebuild catalog product flat

Parameters:
Varien_Event_Observer $observer
Returns:
Mage_CatalogIndex_Model_Observer

Definition at line 371 of file Observer.php.

00372     {
00373         $storeId    = $observer->getEvent()->getStoreId();
00374         $tableName  = $observer->getEvent()->getTable();
00375 
00376         $this->_getIndexer()->updateCatalogProductFlat($storeId, null, $tableName);
00377 
00378         return $this;
00379     }

catalogProductFlatUpdateProduct ( Varien_Event_Observer observer  ) 

Catalog Product Flat update product(s)

Parameters:
Varien_Event_Observer $observer
Returns:
Mage_CatalogIndex_Model_Observer

Definition at line 387 of file Observer.php.

00388     {
00389         $storeId    = $observer->getEvent()->getStoreId();
00390         $tableName  = $observer->getEvent()->getTable();
00391         $productIds = $observer->getEvent()->getProductIds();
00392 
00393         $this->_getIndexer()->updateCatalogProductFlat($storeId, $productIds, $tableName);
00394 
00395         return $this;
00396     }

catalogProductImportAfter ( Varien_Event_Observer observer  ) 

Rebuild index after catalog import

Parameters:
Varien_Event_Observer $observer
Returns:
Mage_CatalogIndex_Model_Observer

Definition at line 224 of file Observer.php.

00225     {
00226         $this->_getIndexer()->plainReindex();
00227         $this->_getAggregator()->clearCacheData();
00228         return $this;
00229     }

cleanCache ( Varien_Event_Observer observer  ) 

Clear aggregated layered navigation data

Parameters:
Varien_Event_Observer $observer
Returns:
Mage_CatalogIndex_Model_Observer

Definition at line 252 of file Observer.php.

00253     {
00254         $tagsArray = $observer->getEvent()->getTags();
00255         $tagName = Mage_CatalogIndex_Model_Aggregation::CACHE_FLAG_NAME;
00256 
00257         if (empty($tagsArray) || in_array($tagName, $tagsArray)) {
00258             $this->_getAggregator()->clearCacheData();
00259         }
00260         return $this;
00261     }

clearPriceAggregation (  ) 

Delete price aggreagation data

Returns:
Mage_CatalogIndex_Model_Observer

Definition at line 284 of file Observer.php.

00285     {
00286         $this->_getAggregator()->clearCacheData(array(
00287             Mage_Catalog_Model_Product_Type_Price::CACHE_TAG
00288         ));
00289         return $this;
00290     }

clearSearchLayerCache (  ) 

Clear layer navigation cache for search results

Returns:
Mage_CatalogIndex_Model_Observer

Definition at line 297 of file Observer.php.

00298     {
00299         $this->_getAggregator()->clearCacheData(array(
00300             Mage_CatalogSearch_Model_Query::CACHE_TAG
00301         ));
00302         return $this;
00303     }

processAfterDeleteEvent ( Varien_Event_Observer observer  ) 

Cleanup product index after product delete

Parameters:
Varien_Event_Observer $observer
Returns:
Mage_CatalogIndex_Model_Observer

Definition at line 164 of file Observer.php.

00165     {
00166         $eventProduct = $observer->getEvent()->getProduct();
00167         $this->_getIndexer()->cleanup($eventProduct);
00168         $parentProductIds = $eventProduct->getParentProductIds();
00169 
00170         if ($parentProductIds) {
00171             $this->_getIndexer()->plainReindex($parentProductIds);
00172         }
00173         return $this;
00174     }

processAfterSaveEvent ( Varien_Event_Observer observer  ) 

Process product after save

Parameters:
Varien_Event_Observer $observer
Returns:
Mage_CatalogIndex_Model_Observer

Definition at line 93 of file Observer.php.

00094     {
00095         $productIds = array();
00096         $eventProduct = $observer->getEvent()->getProduct();
00097         $productIds[] = $eventProduct->getId();
00098 
00099         if (!$eventProduct->getIsMassupdate()) {
00100             $this->_getIndexer()->plainReindex($eventProduct);
00101         } else {
00102             $this->_productIdsMassupdate[] = $eventProduct->getId();
00103         }
00104 
00105         $eventProduct->loadParentProductIds();
00106         $parentProductIds = $eventProduct->getParentProductIds();
00107         if ($parentProductIds && !$eventProduct->getIsMassupdate()) {
00108             $this->_getIndexer()->plainReindex($parentProductIds);
00109         } elseif ($parentProductIds) {
00110             $this->_productIdsMassupdate = array_merge($this->_productIdsMassupdate, $parentProductIds);
00111             $productIds = array_merge($productIds, $parentProductIds);
00112         }
00113         $this->_getAggregator()->clearProductData($productIds);
00114         return $this;
00115     }

processAttributeChangeEvent ( Varien_Event_Observer observer  ) 

Process index data after attribute information was changed

Parameters:
Varien_Event_Observer $observer
Returns:
Mage_CatalogIndex_Model_Observer

Todo:
add flag to attribute model which will notify what options was changed

Definition at line 182 of file Observer.php.

00183     {
00184         /**
00185          * @todo add flag to attribute model which will notify what options was changed
00186          */
00187         $attribute = $observer->getAttribute();
00188         $tags = array(
00189             Mage_Eav_Model_Entity_Attribute::CACHE_TAG.':'.$attribute->getId()
00190         );
00191 
00192         if ($attribute->getOrigData('is_filterable') != $attribute->getIsFilterable()) {
00193             if ($attribute->getIsFilterable() != 0) {
00194                 $this->_getIndexer()->plainReindex(null, $attribute);
00195             } else {
00196                 $this->_getAggregator()->clearCacheData($tags);
00197             }
00198         } elseif ($attribute->getIsFilterable()) {
00199             $this->_getAggregator()->clearCacheData($tags);
00200         }
00201 
00202         return $this;
00203     }

processPriceRuleApplication ( Varien_Event_Observer observer  ) 

Process catalog index after price rules were applied

Parameters:
Varien_Event_Observer $observer
Returns:
Mage_CatalogIndex_Model_Observer

Definition at line 142 of file Observer.php.

00143     {
00144         $eventProduct = $observer->getEvent()->getProduct();
00145         $productCondition = $observer->getEvent()->getProductCondition();
00146         if ($productCondition) {
00147             $eventProduct = $productCondition;
00148         }
00149         $this->_getIndexer()->plainReindex(
00150             $eventProduct,
00151             Mage_CatalogIndex_Model_Indexer::REINDEX_TYPE_PRICE
00152         );
00153 
00154         $this->clearPriceAggregation();
00155         return $this;
00156     }

processPriceScopeChange ( Varien_Event_Observer observer  ) 

Reindex price data after attribute scope change

Parameters:
Varien_Event_Observer $observer
Returns:
Mage_CatalogIndex_Model_Observer

Definition at line 123 of file Observer.php.

00124     {
00125         $configOption   = $observer->getEvent()->getOption();
00126         if ($configOption->isValueChanged()) {
00127             $this->_getIndexer()->plainReindex(
00128                 null,
00129                 Mage_CatalogIndex_Model_Indexer::REINDEX_TYPE_PRICE
00130             );
00131             $this->clearPriceAggregation();
00132         }
00133         return $this;
00134     }

processProductsWebsitesChange ( Varien_Event_Observer observer  ) 

Reindex producs after change websites associations

Parameters:
Varien_Event_Observer $observer
Returns:
Mage_CatalogIndex_Model_Observer

Definition at line 327 of file Observer.php.

00328     {
00329         $productIds = $observer->getEvent()->getProducts();
00330         $this->_getIndexer()->plainReindex($productIds);
00331         $this->_getAggregator()->clearProductData($productIds);
00332         return $this;
00333     }

processStoreAdd ( Varien_Event_Observer observer  ) 

Create index for new store

Parameters:
Varien_Event_Observer $observer
Returns:
Mage_CatalogIndex_Model_Observer

Definition at line 211 of file Observer.php.

00212     {
00213         $store = $observer->getEvent()->getStore();
00214         $this->_getIndexer()->plainReindex(null, null, $store);
00215         return $this;
00216     }

registerParentIds ( Varien_Event_Observer observer  ) 

Load parent ids for products before deleting

Parameters:
Varien_Event_Observer $observer
Returns:
Mage_CatalogIndex_Model_Observer

Definition at line 311 of file Observer.php.

00312     {
00313         $product = $observer->getEvent()->getProduct();
00314         $product->loadParentProductIds();
00315         $productIds = array($product->getId());
00316         $productIds = array_merge($productIds, $product->getParentProductIds());
00317         $this->_getAggregator()->clearProductData($productIds);
00318         return $this;
00319     }

reindexAll (  ) 

Reindex all catalog data

Returns:
Mage_CatalogIndex_Model_Observer

Definition at line 65 of file Observer.php.

00066     {
00067         $this->_getIndexer()->plainReindex();
00068         $this->_getAggregator()->clearCacheData();
00069         return $this;
00070     }

reindexDaily (  ) 

Reindex daily related data (prices)

Returns:
Mage_CatalogIndex_Model_Observer

Definition at line 77 of file Observer.php.

00078     {
00079         $this->_getIndexer()->plainReindex(
00080             null,
00081             Mage_CatalogIndex_Model_Indexer::REINDEX_TYPE_PRICE
00082         );
00083         $this->clearPriceAggregation();
00084         return $this;
00085     }

runQueuedIndexing (  ) 

Run planed reindex

Returns:
Mage_CatalogIndex_Model_Observer

Definition at line 236 of file Observer.php.

00237     {
00238         $flag = Mage::getModel('catalogindex/catalog_index_flag')->loadSelf();
00239         if ($flag->getState() == Mage_CatalogIndex_Model_Catalog_Index_Flag::STATE_QUEUED) {
00240             $this->_getIndexer()->plainReindex();
00241             $this->_getAggregator()->clearCacheData();
00242         }
00243         return $this;
00244     }


Member Data Documentation

$_parentProductIds = array() [protected]

Definition at line 35 of file Observer.php.

$_productIdsMassupdate = array() [protected]

Definition at line 36 of file Observer.php.


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:23:47 2009 for Magento by  doxygen 1.5.8