Mage_Catalog_Model_Product_Flat_Observer Class Reference

List of all members.

Public Member Functions

 catalogEntityAttributeSaveAfter (Varien_Event_Observer $observer)
 catalogProductStatusUpdate (Varien_Event_Observer $observer)
 catalogProductWebsiteUpdate (Varien_Event_Observer $observer)
 catalogProductSaveAfter (Varien_Event_Observer $observer)
 storeAdd (Varien_Event_Observer $observer)
 storeEdit (Varien_Event_Observer $observer)
 storeDelete (Varien_Event_Observer $observer)
 storeGroupSave (Varien_Event_Observer $observer)
 catalogProductImportAfter (Varien_Event_Observer $observer)
 customerGroupSaveAfter (Varien_Event_Observer $observer)
 catalogCategoryChangeProducts (Varien_Event_Observer $observer)

Protected Member Functions

 _getHelper ()
 _getIndexer ()


Detailed Description

Definition at line 35 of file Observer.php.


Member Function Documentation

_getHelper (  )  [protected]

Retrieve Catalog Product Flat Helper

Returns:
Mage_Catalog_Helper_Product_Flat

Definition at line 42 of file Observer.php.

00043     {
00044         return Mage::helper('catalog/product_flat');
00045     }

_getIndexer (  )  [protected]

Retrieve Catalog Product Flat Indexer model

Returns:
Mage_Catalog_Model_Product_Flat_Indexer

Definition at line 52 of file Observer.php.

00052                                      {
00053         return Mage::getSingleton('catalog/product_flat_indexer');
00054     }

catalogCategoryChangeProducts ( Varien_Event_Observer observer  ) 

Update category ids in flat

Parameters:
Varien_Event_Observer $observer
Returns:
Mage_Catalog_Model_Product_Flat_Observer

Definition at line 295 of file Observer.php.

00296     {
00297         if (!$this->_getHelper()->isBuilt()) {
00298             return $this;
00299         }
00300         $this->_getIndexer()->updateAttribute('category_ids');
00301 
00302         return $this;
00303     }

catalogEntityAttributeSaveAfter ( Varien_Event_Observer observer  ) 

Catalog Entity attribute after save process

Parameters:
Varien_Event_Observer $observer
Returns:
Mage_Catalog_Model_Product_Flat_Observer

Definition at line 62 of file Observer.php.

00063     {
00064         if (!$this->_getHelper()->isBuilt()) {
00065             return $this;
00066         }
00067 
00068         $attribute = $observer->getEvent()->getAttribute();
00069         /* @var $attribute Mage_Catalog_Model_Entity_Attribute */
00070 
00071         $enableBefore   = ($attribute->getOrigData('backend_type') == 'static')
00072             || ($this->_getHelper()->isAddFilterableAttributes() && $attribute->getOrigData('is_filterable') > 0)
00073             || ($attribute->getOrigData('used_in_product_listing') == 1)
00074             || ($attribute->getOrigData('used_for_sort_by') == 1);
00075         $enableAfter    = ($attribute->getData('backend_type') == 'static')
00076             || ($this->_getHelper()->isAddFilterableAttributes() && $attribute->getData('is_filterable') > 0)
00077             || ($attribute->getData('used_in_product_listing') == 1)
00078             || ($attribute->getData('used_for_sort_by') == 1);
00079 
00080         if (!$enableAfter && !$enableBefore) {
00081             return $this;
00082         }
00083 
00084         if ($enableBefore && !$enableAfter) {
00085             // delete attribute data from flat
00086             $this->_getIndexer()->prepareDataStorage();
00087         }
00088         else {
00089             $this->_getIndexer()->updateAttribute($attribute->getAttributeCode());
00090         }
00091 
00092         return $this;
00093     }

catalogProductImportAfter ( Varien_Event_Observer observer  ) 

Catalog Product Import After process

Parameters:
Varien_Event_Observer $observer
Returns:
Mage_Catalog_Model_Product_Flat_Observer

Definition at line 257 of file Observer.php.

00258     {
00259         if (!$this->_getHelper()->isBuilt()) {
00260             return $this;
00261         }
00262 
00263         $this->_getIndexer()->rebuild();
00264 
00265         return $this;
00266     }

catalogProductSaveAfter ( Varien_Event_Observer observer  ) 

Catalog Product After Save

Parameters:
Varien_Event_Observer $observer
Returns:
Mage_Catalog_Model_Product_Flat_Observer

Definition at line 153 of file Observer.php.

00153                                                                              {
00154         if (!$this->_getHelper()->isBuilt()) {
00155             return $this;
00156         }
00157 
00158         $product   = $observer->getEvent()->getProduct();
00159         $productId = $product->getId();
00160 
00161         $this->_getIndexer()->saveProduct($productId);
00162 
00163         return $this;
00164     }

catalogProductStatusUpdate ( Varien_Event_Observer observer  ) 

Catalog Product Status Update

Parameters:
Varien_Event_Observer $observer
Returns:
Mage_Catalog_Model_Product_Flat_Observer

Definition at line 101 of file Observer.php.

00102     {
00103         if (!$this->_getHelper()->isBuilt()) {
00104             return $this;
00105         }
00106 
00107         $productId  = $observer->getEvent()->getProductId();
00108         $status     = $observer->getEvent()->getStatus();
00109         $storeId    = $observer->getEvent()->getStoreId();
00110         $storeId    = $storeId > 0 ? $storeId : null;
00111 
00112         $this->_getIndexer()->updateProductStatus($productId, $status, $storeId);
00113 
00114         return $this;
00115     }

catalogProductWebsiteUpdate ( Varien_Event_Observer observer  ) 

Catalog Product Website(s) update

Parameters:
Varien_Event_Observer $observer
Returns:
Mage_Catalog_Model_Product_Flat_Observer

Definition at line 123 of file Observer.php.

00124     {
00125         if (!$this->_getHelper()->isBuilt()) {
00126             return $this;
00127         }
00128 
00129         $websiteIds = $observer->getEvent()->getWebsiteIds();
00130         $productIds = $observer->getEvent()->getProductIds();
00131 
00132         foreach ($websiteIds as $websiteId) {
00133             $website = Mage::app()->getWebsite($websiteId);
00134             foreach ($website->getStores() as $store) {
00135                 if ($observer->getEvent()->getAction() == 'remove') {
00136                     $this->_getIndexer()->removeProduct($productIds, $store->getId());
00137                 }
00138                 else {
00139                     $this->_getIndexer()->updateProduct($productIds, $store->getId());
00140                 }
00141             }
00142         }
00143 
00144         return $this;
00145     }

customerGroupSaveAfter ( Varien_Event_Observer observer  ) 

Customer Group save after process

Parameters:
Varien_Event_Observer_Collection $observer
Returns:
Mage_Catalog_Model_Product_Flat_Observer

Definition at line 274 of file Observer.php.

00275     {
00276         if (!$this->_getHelper()->isBuilt()) {
00277             return $this;
00278         }
00279 
00280         $customerGroup = $observer->getEvent()->getObject();
00281         /* @var $customerGroup Mage_Customer_Model_Group */
00282         if ($customerGroup->dataHasChangedFor($customerGroup->getIdFieldName())
00283             || $customerGroup->dataHasChangedFor('tax_class_id')) {
00284             $this->_getIndexer()->updateEventAttributes();
00285         }
00286         return $this;
00287     }

storeAdd ( Varien_Event_Observer observer  ) 

Add new store flat process

Parameters:
Varien_Event_Observer $observer
Returns:
Mage_Catalog_Model_Product_Flat_Observer

Definition at line 172 of file Observer.php.

00173     {
00174         if (!$this->_getHelper()->isBuilt()) {
00175             return $this;
00176         }
00177 
00178         $store = $observer->getEvent()->getStore();
00179         /* @var $store Mage_Core_Model_Store */
00180         $this->_getIndexer()->rebuild($store->getId());
00181 
00182         return $this;
00183     }

storeDelete ( Varien_Event_Observer observer  ) 

Store delete after process

Parameters:
Varien_Event_Observer $observer
Returns:
Mage_Catalog_Model_Product_Flat_Observer

Definition at line 212 of file Observer.php.

00213     {
00214         if (!$this->_getHelper()->isBuilt()) {
00215             return $this;
00216         }
00217 
00218         $store = $observer->getEvent()->getStore();
00219         /* @var $store Mage_Core_Model_Store */
00220 
00221         $this->_getIndexer()->deleteStore($store->getId());
00222 
00223         return $this;
00224     }

storeEdit ( Varien_Event_Observer observer  ) 

Store edit action, check change store group

Parameters:
Varien_Event_Observer $observer
Returns:
Mage_Catalog_Model_Product_Flat_Observer

Definition at line 191 of file Observer.php.

00192     {
00193         if (!$this->_getHelper()->isBuilt()) {
00194             return $this;
00195         }
00196 
00197         $store = $observer->getEvent()->getStore();
00198         /* @var $store Mage_Core_Model_Store */
00199         if ($store->dataHasChangedFor('group_id')) {
00200             $this->_getIndexer()->rebuild($store->getId());
00201         }
00202 
00203         return $this;
00204     }

storeGroupSave ( Varien_Event_Observer observer  ) 

Store Group Save process

Parameters:
Varien_Event_Observer $observer
Returns:
Mage_Catalog_Model_Product_Flat_Observer

Definition at line 232 of file Observer.php.

00233     {
00234         if (!$this->_getHelper()->isBuilt()) {
00235             return $this;
00236         }
00237 
00238         $group = $observer->getEvent()->getGroup();
00239         /* @var $group Mage_Core_Model_Store_Group */
00240 
00241         if ($group->dataHasChangedFor('website_id')) {
00242             foreach ($group->getStores() as $store) {
00243                 /* @var $store Mage_Core_Model_Store */
00244                 $this->_getIndexer()->rebuild($store->getId());
00245             }
00246         }
00247 
00248         return $this;
00249     }


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

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