Example #1
0
 public function processEvent(Mage_Index_Model_Event $event)
 {
     if ((int) Mage::getStoreConfig('solr/indexer/cms_update')) {
         $solr = Mage::helper('solr')->getSolr();
         $entity = $event->getEntity();
         $type = $event->getType();
         switch ($entity) {
             case DMC_Solr_Model_Cms_Page::ENTITY:
                 if ($type == Mage_Index_Model_Event::TYPE_SAVE) {
                     $object = $event->getDataObject();
                     $document = $this->getSolrDocument();
                     if ($document->setObject($object)) {
                         $solr->addDocument($document);
                         $solr->addDocuments();
                         $solr->commit();
                     }
                 } elseif ($type == Mage_Index_Model_Event::TYPE_DELETE) {
                     $object = $event->getDataObject();
                     $document = $this->getSolrDocument();
                     if ($document->setObject($object)) {
                         $solr->deleteDocument($document);
                         $solr->commit();
                     }
                 }
                 break;
         }
     }
 }
 protected function _registerCatalogCategoryEvent(Mage_Index_Model_Event $event)
 {
     switch ($event->getType()) {
         case Mage_Index_Model_Event::TYPE_SAVE:
             /** @var $category Mage_Catalog_Model_Category */
             $category = $event->getDataObject();
             $productIds = $category->getAffectedProductIds();
             if (!$category->getData('is_active')) {
                 $event->addNewData('catalogsearch_delete_category_id', array_merge(array($category->getId()), $category->getAllChildren(TRUE)));
                 if ($productIds) {
                     $event->addNewData('catalogsearch_update_product_id', $productIds);
                 }
             } elseif ($productIds) {
                 $event->addNewData('catalogsearch_update_product_id', $productIds);
                 $event->addNewData('catalogsearch_update_category_id', array($category->getId()));
             } elseif ($movedCategoryId = $category->getMovedCategoryId()) {
                 $event->addNewData('catalogsearch_update_category_id', array($movedCategoryId));
             } else {
                 $event->addNewData('catalogsearch_update_category_id', array($category->getId()));
             }
             break;
         case Mage_Index_Model_Event::TYPE_DELETE:
             /** @var $category Mage_Catalog_Model_Category */
             $category = $event->getDataObject();
             $event->addNewData('catalogsearch_delete_category_id', $category->getId());
             break;
     }
     return $this;
 }
Example #3
0
 /**
  * This method is called by the core indexer process
  * in case of saving (insert/update) a product
  */
 protected function _processEvent(Mage_Index_Model_Event $event)
 {
     $solr = Mage::helper('solr')->getSolr();
     $object = $event->getDataObject();
     // if the product is not active anymore, we will remove it from solr index
     if ($object->getStatus() != Mage_Catalog_Model_Product_Status::STATUS_ENABLED) {
         $solr->deleteByQuery("id:{$object->getId()}");
         Mage::helper('solr/log')->addDebugMessage('The object #' . $object->getId() . ' is not active and was therefore deleted.');
         Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('solr')->__('The Product has been removed from Solr.'));
         return;
     }
     // $object contains the full product object
     if ($event->getEntity() == 'catalog_product' && $event->getType() == 'save' && $event->getDataObject()) {
         if ((int) Mage::getStoreConfig('solr/indexer/product_update')) {
             $storeId = $object->getStoreId();
             // to-do
             // index just those store views, we need
             /*
             $adapter = new DMC_Solr_Model_SolrServer_Adapter_Product();
             $document = $adapter->getSolrDocument();
             if($document->setObject($object)) {
                 $document->setStoreId($storeId);
                 // add doducment to adapter object
                 $solr->addDocument($document);
             
                 #echo '<pre>';
                 #print_r($document);exit;
             }
             
             // send documents to solr
             $solr->addDocuments();
             */
             if (!$storeId) {
                 $storeIds = Mage::helper('solr')->getStoresForReindex();
             } else {
                 $storeIds = array($storeId);
             }
             $adapter = new DMC_Solr_Model_SolrServer_Adapter_Product();
             $productId = $object->getId();
             foreach ($storeIds as $storeId) {
                 $object = Mage::getModel('catalog/product')->setStoreId($storeId)->load($productId);
                 $document = $adapter->getSolrDocument();
                 if ($document->setObject($object)) {
                     $document->setStoreId($storeId);
                     $solr->addDocument($document);
                 }
             }
             $solr->addDocuments();
             // commit data to solr
             $solr->commit();
             Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('solr')->__('The Product has been updated at Solr.'));
         }
     }
 }
 public function registerFulltextIndexerEvent(Mage_CatalogSearch_Model_Indexer_Fulltext $indexer, Mage_Index_Model_Event $event)
 {
     switch ($event->getType()) {
         case Mage_Index_Model_Event::TYPE_SAVE:
             $page = $event->getDataObject();
             $event->addNewData('catalogsearch_update_cms_page_id', $page->getId());
             break;
         case Mage_Index_Model_Event::TYPE_DELETE:
             $page = $event->getDataObject();
             $event->addNewData('catalogsearch_delete_cms_page_id', $page->getId());
             break;
     }
     return $indexer;
 }
Example #5
0
 public function processEvent(Mage_Index_Model_Event $event)
 {
     if ((int) Mage::getStoreConfig('solr/indexer/product_update')) {
         $solr = Mage::helper('solr')->getSolr();
         $entity = $event->getEntity();
         $type = $event->getType();
         switch ($entity) {
             case Mage_Catalog_Model_Product::ENTITY:
                 if ($type == Mage_Index_Model_Event::TYPE_MASS_ACTION) {
                 } elseif ($type == Mage_Index_Model_Event::TYPE_SAVE) {
                     $object = $event->getDataObject();
                     $document = $this->getSolrDocument();
                     if ($document->setObject($object)) {
                         $solr->addDocument($document);
                         $solr->addDocuments();
                         $solr->commit();
                     }
                 } elseif ($type == Mage_Index_Model_Event::TYPE_DELETE) {
                 }
                 break;
             case Mage_Catalog_Model_Resource_Eav_Attribute::ENTITY:
                 $this->_skipReindex($event);
                 break;
         }
     }
 }
 protected function _registerCatalogProductEvent(Mage_Index_Model_Event $event)
 {
     switch ($event->getType()) {
         case Mage_Index_Model_Event::TYPE_SAVE:
             /** @var $product Mage_Catalog_Model_Product */
             $product = $event->getDataObject();
             $delete = FALSE;
             $visibleInSite = Mage::getSingleton('catalog/product_visibility')->getVisibleInSiteIds();
             if ($product->getStatus() == Mage_Catalog_Model_Product_Status::STATUS_DISABLED) {
                 $delete = TRUE;
             } elseif (!in_array($product->getData('visibility'), $visibleInSite)) {
                 $delete = TRUE;
             }
             if ($delete) {
                 $event->addNewData('catalogsearch_delete_product_id', $product->getId());
                 $event->addNewData('catalogsearch_update_category_id', $product->getCategoryIds());
             } else {
                 $event->addNewData('catalogsearch_update_product_id', $product->getId());
                 /* product_categories is filled in Observer::saveProduct */
                 if (isset(static::$product_categories[$product->getId()])) {
                     $oldCategories = static::$product_categories[$product->getId()];
                     $newCategories = $product->getCategoryIds();
                     $diffCategories = array_merge(array_diff($oldCategories, $newCategories), array_diff($newCategories, $oldCategories));
                     $event->addNewData('catalogsearch_update_category_id', $diffCategories);
                 }
             }
             break;
         case Mage_Index_Model_Event::TYPE_DELETE:
             /** @var $product Mage_Catalog_Model_Product */
             $product = $event->getDataObject();
             $event->addNewData('catalogsearch_delete_product_id', $product->getId());
             $event->addNewData('catalogsearch_update_category_id', $product->getCategoryIds());
             break;
         case Mage_Index_Model_Event::TYPE_MASS_ACTION:
             /** @var $actionObject Varien_Object */
             $actionObject = $event->getDataObject();
             $reindexData = array();
             // Check if status changed
             $attrData = $actionObject->getAttributesData();
             if (isset($attrData['status'])) {
                 $reindexData['catalogsearch_status'] = $attrData['status'];
             }
             // Check changed websites
             if ($actionObject->getWebsiteIds()) {
                 $reindexData['catalogsearch_website_ids'] = $actionObject->getWebsiteIds();
                 $reindexData['catalogsearch_action_type'] = $actionObject->getActionType();
             }
             $reindexData['catalogsearch_force_reindex'] = TRUE;
             if ($actionObject->getIsDeleted()) {
                 $reindexData['catalogsearch_delete_product_id'] = $actionObject->getProductIds();
             } else {
                 $reindexData['catalogsearch_product_ids'] = $actionObject->getProductIds();
             }
             foreach ($reindexData as $k => $v) {
                 $event->addNewData($k, $v);
             }
             break;
     }
     return $this;
 }
 /**
  * Process event based on event state data
  *
  * @param Mage_Index_Model_Event $event Indexing event.
  *
  * @return void
  */
 protected function _processEvent(Mage_Index_Model_Event $event)
 {
     $searchTerm = $event->getDataObject();
     if ($event->getType() == Mage_Index_Model_Event::TYPE_SAVE) {
         $this->reindex($searchTerm);
     }
 }
Example #8
0
 protected function _registerCatalogProductEvent(Mage_Index_Model_Event $event)
 {
     switch ($event->getType()) {
         case Mage_Index_Model_Event::TYPE_SAVE:
             /** @var $product Mage_Catalog_Model_Product */
             $product = $event->getDataObject();
             $event->addNewData('catalogsearch_update_product_id', $product->getId());
             $event->addNewData('catalogsearch_update_category_id', $product->getCategoryIds());
             /* product_categories is filled in Observer::saveProduct */
             if (isset(static::$product_categories[$product->getId()])) {
                 $oldCategories = static::$product_categories[$product->getId()];
                 $newCategories = $product->getCategoryIds();
                 $diffCategories = array_merge(array_diff($oldCategories, $newCategories), array_diff($newCategories, $oldCategories));
                 $event->addNewData('catalogsearch_update_category_id', $diffCategories);
             }
         case Mage_Index_Model_Event::TYPE_DELETE:
             /** @var $product Mage_Catalog_Model_Product */
             $product = $event->getDataObject();
             $event->addNewData('catalogsearch_update_product_id', $product->getId());
             $event->addNewData('catalogsearch_update_category_id', $product->getCategoryIds());
             break;
         case Mage_Index_Model_Event::TYPE_MASS_ACTION:
             /** @var $actionObject Varien_Object */
             $actionObject = $event->getDataObject();
             $event->addNewData('catalogsearch_update_product_id', $actionObject->getProductIds());
             break;
     }
     return $this;
 }
Example #9
0
 public function testMatchEventCaching()
 {
     $this->testMatchEventForChangedStoreGroup();
     $storeGroup = $this->_event->getDataObject();
     $storeGroup->expects($this->any())->method('dataHasChangedFor')->will($this->returnValue(false));
     $this->assertTrue($this->_model->matchEvent($this->_event));
 }
 /**
  * Event handler for CMS page save events
  *
  * @param Mage_Index_Model_Event $event
  */
 public function CmsPageSave(Mage_Index_Model_Event $event)
 {
     $storeIds = $event->getDataObject()->getStores();
     $pageId = $event->getData('solr_update_page_id');
     foreach ($storeIds as $storeId) {
         $this->rebuildStoreIndex($storeId, $pageId);
     }
 }
 /**
  * Process event based on event state data
  *
  * @param Mage_Index_Model_Event $event Indexing event.
  *
  * @return void
  */
 protected function _processEvent(Mage_Index_Model_Event $event)
 {
     $category = $event->getDataObject();
     if ($event->getType() == Mage_Index_Model_Event::TYPE_SAVE) {
         if (Mage::helper('smile_elasticsearch')->isActiveEngine()) {
             $this->reindex($category);
         }
     }
 }
Example #12
0
 /**
  * Register data required by product type process in event object
  *
  * @param Mage_Index_Model_Event $event
  */
 public function registerEvent(Mage_Index_Model_Event $event)
 {
     $attributes = array('allow_open_amount', 'open_amount_min', 'open_amount_max');
     $entity = $event->getEntity();
     if ($entity == Mage_Catalog_Model_Product::ENTITY) {
         switch ($event->getType()) {
             case Mage_Index_Model_Event::TYPE_SAVE:
                 /* @var $product Mage_Catalog_Model_Product */
                 $product = $event->getDataObject();
                 $reindexPrice = $product->getAmountsHasChanged();
                 foreach ($attributes as $code) {
                     if ($product->dataHasChangedFor($code)) {
                         $reindexPrice = true;
                         break;
                     }
                 }
                 if ($reindexPrice) {
                     $event->addNewData('product_type_id', $product->getTypeId());
                     $event->addNewData('reindex_price', 1);
                 }
                 break;
             case Mage_Index_Model_Event::TYPE_MASS_ACTION:
                 /* @var $actionObject Varien_Object */
                 $actionObject = $event->getDataObject();
                 $reindexPrice = false;
                 // check if attributes changed
                 $attrData = $actionObject->getAttributesData();
                 if (is_array($attrData)) {
                     foreach ($attributes as $code) {
                         if (array_key_exists($code, $attrData)) {
                             $reindexPrice = true;
                             break;
                         }
                     }
                 }
                 if ($reindexPrice) {
                     $event->addNewData('reindex_price_product_ids', $actionObject->getProductIds());
                 }
                 break;
         }
     }
 }
 /**
  * Register data required by process in event object
  * @param Mage_Index_Model_Event $event
  */
 protected function _registerEvent(Mage_Index_Model_Event $event)
 {
     $dataObj = $event->getDataObject();
     if ($event->getType() == Mage_Index_Model_Event::TYPE_SAVE) {
         $event->addNewData('merlinsearch_update_product_id', $dataObj->getId());
     } elseif ($event->getType() == Mage_Index_Model_Event::TYPE_DELETE) {
         $event->addNewData('merlinsearch_delete_product_id', $dataObj->getId());
     } elseif ($event->getType() == Mage_Index_Model_Event::TYPE_MASS_ACTION) {
         $event->addNewData('merlinsearch_mass_action_product_ids', $dataObj->getProductIds());
     }
 }
Example #14
0
 protected function registerCatalogProductEvent(Mage_Index_Model_Event $event)
 {
     switch ($event->getType()) {
         case Mage_Index_Model_Event::TYPE_SAVE:
             $product = $event->getDataObject();
             /** @var Mage_Catalog_Model_Product $product */
             $event->addNewData('solr_update_product_id', $product->getId());
             break;
         case Mage_Index_Model_Event::TYPE_MASS_ACTION:
             break;
     }
 }
Example #15
0
 protected function _registerProductEvent(Mage_Index_Model_Event $event)
 {
     $product = $event->getDataObject();
     $dataChange2 = false;
     if ($product->dataHasChangedFor('status') && $product->getData('status') == "1" || $product->dataHasChangedFor('visibility') && $product->getData('visibility') != "1") {
         $dataChange2 = true;
     }
     $dataChange = $product->dataHasChangedFor('url_key') || $product->getIsChangedCategories() || $product->getIsChangedWebsites() || $dataChange2;
     if (!$product->getExcludeUrlRewrite() && $dataChange) {
         $event->addNewData('rewrite_product_ids', array($product->getId()));
     }
 }
 protected function _registerCatalogCategoryEvent(Mage_Index_Model_Event $event)
 {
     switch ($event->getType()) {
         case Mage_Index_Model_Event::TYPE_SAVE:
             /** @var Mage_Catalog_Model_Category $category*/
             $category = $event->getDataObject();
             $productIds = array();
             if ($this->config->indexAllCategoryProductsOnCategoryUpdate()) {
                 $categories = array_merge(array($category->getId()), $category->getAllChildren(true));
                 $collection = Mage::getResourceModel('catalog/product_collection');
                 $collection->joinField('category_id', 'catalog/category_product', 'category_id', 'product_id = entity_id', null, 'left');
                 $collection->addAttributeToFilter('category_id', array('in' => $categories));
                 $productIds = $collection->getAllIds();
             } elseif ($this->config->indexProductOnCategoryProductsUpdate()) {
                 $productIds = $category->getAffectedProductIds();
             }
             if (!$category->getData('is_active')) {
                 $categories = array_merge(array($category->getId()), $category->getAllChildren(true));
                 $event->addNewData('catalogsearch_delete_category_id', $categories);
                 if ($productIds) {
                     $event->addNewData('catalogsearch_update_product_id', $productIds);
                 }
             } elseif ($productIds) {
                 $event->addNewData('catalogsearch_update_product_id', $productIds);
                 $event->addNewData('catalogsearch_update_category_id', array($category->getId()));
             } elseif ($movedCategoryId = $category->getMovedCategoryId()) {
                 $event->addNewData('catalogsearch_update_category_id', array($movedCategoryId));
             } else {
                 $event->addNewData('catalogsearch_update_category_id', array($category->getId()));
             }
             break;
         case Mage_Index_Model_Event::TYPE_DELETE:
             /** @var $category Mage_Catalog_Model_Category */
             $category = $event->getDataObject();
             $event->addNewData('catalogsearch_delete_category_id', $category->getId());
             break;
     }
     return $this;
 }
 /**
  * Register data required by process in event object
  * @param Mage_Index_Model_Event $event
  */
 protected function _registerEvent(Mage_Index_Model_Event $event)
 {
     $dataObj = $event->getDataObject();
     if ($event->getType() == Mage_Index_Model_Event::TYPE_SAVE) {
         $event->addNewData('charzam_priceindex_update_product_id', $dataObj->getId());
         return;
     }
     if ($event->getType() == Mage_Index_Model_Event::TYPE_DELETE) {
         $event->addNewData('charzam_priceindex_delete_product_id', $dataObj->getId());
         return;
     }
     if ($event->getType() == Mage_Index_Model_Event::TYPE_MASS_ACTION) {
         $event->addNewData('charzam_priceindex_mass_action_product_ids', $dataObj->getProductIds());
         return;
     }
 }
Example #18
0
 /**
  * Process event
  *
  * @param Mage_Index_Model_Event $event
  */
 protected function _processEvent(Mage_Index_Model_Event $event)
 {
     $data = $event->getNewData();
     if (!empty($data['catalog_url_reindex_all'])) {
         $this->reindexAll();
         return $this;
     }
     // Force rewrites history saving
     $dataObject = $event->getDataObject();
     if ($dataObject instanceof Varien_Object && $dataObject->hasData('save_rewrites_history')) {
         $this->_getResource()->isSaveHistory($dataObject->getData('save_rewrites_history'));
     }
     if (isset($data['rewrite_category_ids']) || isset($data['rewrite_product_ids'])) {
         $this->callEventHandler($event);
     }
     $this->_getResource()->resetSaveHistory();
     return $this;
 }
 /**
  * @param Mage_Index_Model_Event $event
  * @return void
  */
 protected function _registerEvent(Mage_Index_Model_Event $event)
 {
     /* @var $entity Varien_Object */
     $entity = $event->getDataObject();
     // could be a catalog/product or catalog/category entity, too
     $eventType = $event->getType();
     $attrCode = Netzarbeiter_GroupsCatalog2_Helper_Data::HIDE_GROUPS_ATTRIBUTE;
     if ($eventType == Mage_Index_Model_Event::TYPE_SAVE) {
         if ($entity->dataHasChangedFor($attrCode)) {
             $event->setData('entity_ids', array($entity->getId()));
         }
     } elseif ($eventType == Mage_Index_Model_Event::TYPE_MASS_ACTION) {
         $attributeData = $entity->getAttributesData();
         if (isset($attributeData[$attrCode])) {
             $event->setData('entity_ids', $this->_getEntityIdsFromEntity($entity));
         }
     }
 }
Example #20
0
 protected function _registerCatalogProductMassActionEvent(Mage_Index_Model_Event $event)
 {
     $actionObject = $event->getDataObject();
     $attributes = $this->_getDependentAttributes();
     $reindexPrice = false;
     $attrData = $actionObject->getAttributesData();
     if (is_array($attrData)) {
         foreach ($attributes as $code) {
             if (array_key_exists($code, $attrData)) {
                 $reindexPrice = true;
                 break;
             }
         }
     }
     if ($reindexPrice) {
         $event->addNewData('reindex_price_product_ids', $actionObject->getProductIds());
     }
     return $this;
 }
Example #21
0
 /**
  * Save data in the event object to be processed 
  * @param Mage_Index_Model_Event $event
  */
 protected function _registerEvent(Mage_Index_Model_Event $event)
 {
     $dataObj = $event->getDataObject();
     $storeId = $dataObj->getStoreId();
     if ($dataObj->getId()) {
         if ($storeId) {
             $event->addNewData('nanowebg_elasticsearch_store_id', $storeId);
         }
         if ($event->getType() == Mage_Index_Model_Event::TYPE_SAVE) {
             $event->addNewData('nanowebg_elasticsearch_update_product_id', $dataObj->getId());
         } elseif ($event->getType() == Mage_Index_Model_Event::TYPE_DELETE) {
             $event->addNewData('nanowebg_elasticsearch_delete_product_id', $dataObj->getId());
         } elseif ($event->getType() == Mage_Index_Model_Event::TYPE_MASS_ACTION) {
             $event->addNewData('nanowebg_elasticsearch_mass_action_product_ids', $dataObj->getProductIds());
         }
     } else {
         $this->changeStatus(Mage_Index_Model_Process::STATUS_REQUIRE_REINDEX);
     }
 }
Example #22
0
 public function matchEvent(Mage_Index_Model_Event $event)
 {
     $data = $event->getNewData();
     if (isset($data[self::EVENT_MATCH_RESULT_KEY])) {
         return $data[self::EVENT_MATCH_RESULT_KEY];
     }
     $entity = $event->getEntity();
     if ($entity == Mage_Core_Model_Store::ENTITY) {
         $store = $event->getDataObject();
         if ($store && $store->isObjectNew()) {
             $result = true;
         } else {
             $result = false;
         }
     } else {
         $result = parent::matchEvent($event);
     }
     $event->addNewData(self::EVENT_MATCH_RESULT_KEY, $result);
     return $result;
 }
Example #23
0
 /**
  * Register data required by catatalog product process in event object
  *
  * @param Mage_Index_Model_Event $event
  * @return Mage_CatalogSearch_Model_Indexer_Search
  */
 protected function _registerCatalogProductEvent(Mage_Index_Model_Event $event)
 {
     switch ($event->getType()) {
         case Mage_Index_Model_Event::TYPE_SAVE:
             /* @var $product Mage_Catalog_Model_Product */
             $product = $event->getDataObject();
             $event->addNewData('catalogsearch_update_product_id', $product->getId());
             break;
         case Mage_Index_Model_Event::TYPE_DELETE:
             /* @var $product Mage_Catalog_Model_Product */
             $product = $event->getDataObject();
             $event->addNewData('catalogsearch_delete_product_id', $product->getId());
             break;
         case Mage_Index_Model_Event::TYPE_MASS_ACTION:
             /* @var $actionObject Varien_Object */
             $actionObject = $event->getDataObject();
             $reindexData = array();
             $rebuildIndex = false;
             // check if status changed
             $attrData = $actionObject->getAttributesData();
             if (isset($attrData['status'])) {
                 $rebuildIndex = true;
                 $reindexData['catalogsearch_status'] = $attrData['status'];
             }
             // check changed websites
             if ($actionObject->getWebsiteIds()) {
                 $rebuildIndex = true;
                 $reindexData['catalogsearch_website_ids'] = $actionObject->getWebsiteIds();
                 $reindexData['catalogsearch_action_type'] = $actionObject->getActionType();
             }
             // register affected products
             if ($rebuildIndex) {
                 $reindexData['catalogsearch_product_ids'] = $actionObject->getProductIds();
                 foreach ($reindexData as $k => $v) {
                     $event->addNewData($k, $v);
                 }
             }
             break;
     }
     return $this;
 }
Example #24
0
 /**
  * Register data required by process attribute save in event object
  *
  * @param Mage_Index_Model_Event $event
  * @return Mage_Catalog_Model_Product_Indexer_Eav
  */
 protected function _registerCatalogAttributeSaveEvent(Mage_Index_Model_Event $event)
 {
     /* @var $attribute Mage_Catalog_Model_Resource_Eav_Attribute */
     $attribute = $event->getDataObject();
     if ($attribute->isIndexable()) {
         $before = $attribute->getOrigData('is_filterable') || $attribute->getOrigData('is_filterable_in_search') || $attribute->getOrigData('is_visible_in_advanced_search');
         $after = $attribute->getData('is_filterable') || $attribute->getData('is_filterable_in_search') || $attribute->getData('is_visible_in_advanced_search');
         if (!$before && $after || $before && !$after) {
             $event->addNewData('reindex_attribute', 1);
             $event->addNewData('attribute_index_type', $attribute->getIndexType());
             $event->addNewData('is_indexable', $after);
         }
     }
     return $this;
 }
Example #25
0
 /**
  * Register event data during category save process
  *
  * @param Mage_Index_Model_Event $event
  */
 protected function _registerCategoryEvent(Mage_Index_Model_Event $event)
 {
     $category = $event->getDataObject();
     /**
      * Check if product categories data was changed
      */
     if ($category->getIsChangedProductList()) {
         $event->addNewData('products_was_changed', true);
     }
     /**
      * Check if category has another affected category ids (category move result)
      */
     if ($category->getAffectedCategoryIds()) {
         $event->addNewData('affected_category_ids', $category->getAffectedCategoryIds());
     }
 }
Example #26
0
 /**
  * Register core store delete process
  *
  * @param Mage_Index_Model_Event $event
  * @return Mage_Catalog_Model_Product_Indexer_Flat
  */
 protected function _registerCoreStoreEvent(Mage_Index_Model_Event $event)
 {
     if ($event->getType() == Mage_Index_Model_Event::TYPE_DELETE) {
         /* @var $store Mage_Core_Model_Store */
         $store = $event->getDataObject();
         $event->addNewData('catalog_product_flat_delete_store_id', $store->getId());
     }
     return $this;
 }
Example #27
0
 /**
  * Register data required by product mass action process in event object
  *
  * @param Mage_Index_Model_Event $event
  * @return Mage_CatalogInventory_Model_Indexer_Stock
  */
 protected function _registerCatalogProductMassActionEvent(Mage_Index_Model_Event $event)
 {
     /* @var $actionObject Varien_Object */
     $actionObject = $event->getDataObject();
     $attributes = array('status');
     $reindexStock = false;
     // check if attributes changed
     $attrData = $actionObject->getAttributesData();
     if (is_array($attrData)) {
         foreach ($attributes as $attributeCode) {
             if (array_key_exists($attributeCode, $attrData)) {
                 $reindexStock = true;
                 break;
             }
         }
     }
     // check changed websites
     if ($actionObject->getWebsiteIds()) {
         $reindexStock = true;
     }
     // register affected products
     if ($reindexStock) {
         $event->addNewData('reindex_stock_product_ids', $actionObject->getProductIds());
     }
     return $this;
 }
Example #28
0
 protected function _registerTagRelation(Mage_Index_Model_Event $event)
 {
     if ($event->getType() == Mage_Index_Model_Event::TYPE_SAVE) {
         $event->addNewData('tag_reindex_tag_id', $event->getDataObject()->getTagId());
     }
 }
Example #29
0
 /**
  * Process event
  *
  * @param Mage_Index_Model_Event $event
  */
 protected function _processEvent(Mage_Index_Model_Event $event)
 {
     $data = $event->getNewData();
     if (!empty($data['catalog_url_reindex_all'])) {
         $this->reindexAll();
     }
     /* @var $urlModel Mage_Catalog_Model_Url */
     $urlModel = Mage::getSingleton('catalog/url');
     // Force rewrites history saving
     $dataObject = $event->getDataObject();
     if ($dataObject instanceof Varien_Object && $dataObject->hasData('save_rewrites_history')) {
         $urlModel->setShouldSaveRewritesHistory($dataObject->getData('save_rewrites_history'));
     }
     if (isset($data['rewrite_product_ids'])) {
         $urlModel->clearStoreInvalidRewrites();
         // Maybe some products were moved or removed from website
         foreach ($data['rewrite_product_ids'] as $productId) {
             $urlModel->refreshProductRewrite($productId);
         }
     }
     if (isset($data['rewrite_category_ids'])) {
         $urlModel->clearStoreInvalidRewrites();
         // Maybe some categories were moved
         foreach ($data['rewrite_category_ids'] as $categoryId) {
             $urlModel->refreshCategoryRewrite($categoryId);
         }
     }
 }
Example #30
0
 /**
  * Process event
  * @param Mage_Index_Model_Event $event
  * @return void
  */
 protected function _processEvent(Mage_Index_Model_Event $event)
 {
     $data = $event->getNewData();
     $event_model = $event->getDataObject();
     if (!empty($data['rewards_customer_points_match_result'])) {
         try {
             if ($event->getEntity() == self::REWARDS_TRANSFER_ENTITY) {
                 if ($event_model) {
                     $transfer = $event_model;
                     $this->_getResource()->reindexUpdate($transfer->getCustomerId());
                 }
             } elseif ($event->getEntity() == self::REWARDS_CUSTOMER_ENTITY) {
                 if ($event_model) {
                     $customer = $event_model;
                     $this->_getResource()->reindexUpdate($customer->getId());
                 }
             } else {
                 // Model entity type was not recognized
             }
         } catch (Exception $e) {
             Mage::logException($e);
             Mage::helper('rewards/debug')->logException($e);
             $this->reindexAll();
         }
     }
 }