Mage_CatalogSearch_Model_Fulltext_Observer Class Reference

List of all members.

Public Member Functions

 refreshProductIndex (Varien_Event_Observer $observer)
 cleanProductIndex (Varien_Event_Observer $observer)
 eavAttributeChange (Varien_Event_Observer $observer)
 refreshIndexAfterImport ()
 refreshStoreIndex (Varien_Event_Observer $observer)
 catalogProductWebsiteUpdate (Varien_Event_Observer $observer)
 cleanStoreIndex (Varien_Event_Observer $observer)

Protected Member Functions

 _getFulltextModel ()


Detailed Description

Definition at line 34 of file Observer.php.


Member Function Documentation

_getFulltextModel (  )  [protected]

Retrieve fulltext (indexer) model

Returns:
Mage_CatalogSearch_Model_Fulltext

Definition at line 41 of file Observer.php.

00042     {
00043         return Mage::getSingleton('catalogsearch/fulltext');
00044     }

catalogProductWebsiteUpdate ( Varien_Event_Observer observer  ) 

Catalog Product mass website update

Parameters:
Varien_Event_Observer $observer
Returns:
Mage_CatalogSearch_Model_Fulltext_Observer

Definition at line 153 of file Observer.php.

00154     {
00155         $websiteIds = $observer->getEvent()->getWebsiteIds();
00156         $productIds = $observer->getEvent()->getProductIds();
00157         $actionType = $observer->getEvent()->getAction();
00158 
00159         foreach ($websiteIds as $websiteId) {
00160             foreach (Mage::app()->getWebsite($websiteId)->getStoreIds() as $storeId) {
00161                 if ($actionType == 'remove') {
00162                     $this->_getFulltextModel()
00163                         ->cleanIndex($storeId, $productIds)
00164                         ->resetSearchResults();
00165                 }
00166                 elseif ($actionType == 'add') {
00167                     $this->_getFulltextModel()
00168                         ->rebuildIndex($storeId, $productIds)
00169                         ->resetSearchResults();
00170                 }
00171             }
00172         }
00173 
00174         return $this;
00175     }

cleanProductIndex ( Varien_Event_Observer observer  ) 

Clean product index when product deleted or marked as unsearchable/invisible

Parameters:
Varien_Event_Observer $observer
Returns:
Mage_CatalogSearch_Model_Fulltext_Observer

Definition at line 69 of file Observer.php.

00070     {
00071         $product = $observer->getEvent()->getProduct();
00072 
00073         $this->_getFulltextModel()
00074             ->cleanIndex(null, $product->getId())
00075             ->resetSearchResults();
00076 
00077         return $this;
00078     }

cleanStoreIndex ( Varien_Event_Observer observer  ) 

Store delete processing

Parameters:
Varien_Event_Observer $observer
Returns:
Mage_CatalogSearch_Model_Fulltext_Observer

Definition at line 183 of file Observer.php.

00184     {
00185         $store = $observer->getEvent()->getStore();
00186         /* @var $store Mage_Core_Model_Store */
00187 
00188         $this->_getFulltextModel()
00189             ->cleanIndex($store->getId());
00190 
00191         return $this;
00192     }

eavAttributeChange ( Varien_Event_Observer observer  ) 

Update all attribute-dependant index

Parameters:
Varien_Event_Observer $observer
Returns:
Mage_CatalogSearch_Model_Fulltext_Observer

Definition at line 86 of file Observer.php.

00087     {
00088         $attribute = $observer->getEvent()->getAttribute();
00089         /* @var $attribute Mage_Eav_Model_Entity_Attribute */
00090         $entityType = Mage::getSingleton('eav/config')->getEntityType('catalog_product');
00091         /* @var $entityType Mage_Eav_Model_Entity_Type */
00092 
00093         if ($attribute->getEntityTypeId() != $entityType->getId()) {
00094             return $this;
00095         }
00096         $delete = $observer->getEventName() == 'eav_entity_attribute_delete_after';
00097 
00098         if (!$delete && !$attribute->dataHasChangedFor('is_searchable')) {
00099             return $this;
00100         }
00101 
00102         $showNotice = false;
00103         if ($delete) {
00104             if ($attribute->getIsSearchable()) {
00105                 $showNotice = true;
00106             }
00107         }
00108         elseif ($attribute->dataHasChangedFor('is_searchable')) {
00109             $showNotice = true;
00110         }
00111 
00112         if ($showNotice) {
00113             $url = Mage::getSingleton('adminhtml/url')->getUrl('adminhtml/system_cache');
00114             Mage::getSingleton('adminhtml/session')->addNotice(
00115                 Mage::helper('catalogsearch')->__('Attribute setting change related with Search Index. Please run <a href="%s">Rebuild Search Index</a> process', $url)
00116             );
00117         }
00118 
00119         return $this;
00120     }

refreshIndexAfterImport (  ) 

Rebuild index after import

Returns:
Mage_CatalogSearch_Model_Fulltext_Observer

Definition at line 127 of file Observer.php.

00128     {
00129         $this->_getFulltextModel()
00130             ->rebuildIndex();
00131         return $this;
00132     }

refreshProductIndex ( Varien_Event_Observer observer  ) 

Update product index when product data updated

Parameters:
Varien_Event_Observer $observer
Returns:
Mage_CatalogSearch_Model_Fulltext_Observer

Definition at line 52 of file Observer.php.

00053     {
00054         $product = $observer->getEvent()->getProduct();
00055 
00056         $this->_getFulltextModel()
00057             ->rebuildIndex(null, $product->getId())
00058             ->resetSearchResults();
00059 
00060         return $this;
00061     }

refreshStoreIndex ( Varien_Event_Observer observer  ) 

Refresh fulltext index when we add new store

Parameters:
Varien_Event_Observer $observer
Returns:
Mage_CatalogSearch_Model_Fulltext_Observer

Definition at line 140 of file Observer.php.

00141     {
00142         $storeId = $observer->getEvent()->getStore()->getId();
00143         $this->_getFulltextModel()->rebuildIndex($storeId);
00144         return $this;
00145     }


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

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