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; }
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; }
/** * @param Mana_Seo_Model_UrlIndexer $indexer * @param Mage_Index_Model_Event $event */ public function register($indexer, $event) { $db = $this->_getReadAdapter(); if ($event->getEntity() == 'mana_filters/filter2') { if ($event->getData('data_object')->getType() == 'category') { $event->addNewData('process_category_filter', true); } } elseif ($event->getEntity() == 'mana_filters/filter2_store') { $attributeType = $db->fetchOne($db->select()->from(array('f' => $this->getTable('mana_filters/filter2')), 'type')->where('f.id = ?', $event->getData('data_object')->getGlobalId())); if ($attributeType == 'category') { $event->addNewData('process_category_filter', true); } } }
/** * @param Mana_Seo_Model_UrlIndexer $indexer * @param Mage_Index_Model_Event $event */ public function register($indexer, $event) { $db = $this->_getReadAdapter(); if ($event->getEntity() == Mage_Catalog_Model_Resource_Eav_Attribute::ENTITY) { $event->addNewData('attribute_id', $event->getData('data_object')->getId()); } elseif ($event->getEntity() == 'mana_filters/filter2') { if ($attributeId = $this->getFilterResource()->getAttributeId($event->getData('data_object'))) { $event->addNewData('attribute_id', $attributeId); } } elseif ($event->getEntity() == 'mana_filters/filter2_store') { if ($attributeId = $this->getFilterStoreResource()->getAttributeId($event->getData('data_object'))) { $event->addNewData('attribute_id', $attributeId); } } }
protected function _registerEvent(Mage_Index_Model_Event $event) { $dataObj = $event->getDataObject(); if ($event->getType() == Mage_Index_Model_Event::TYPE_SAVE) { $event->addNewData('amconf_update_product_id', $dataObj->getId()); } else { if ($event->getType() == Mage_Index_Model_Event::TYPE_DELETE) { $event->addNewData('amconf_delete_product_id', $dataObj->getId()); } else { if ($event->getType() == Mage_Index_Model_Event::TYPE_MASS_ACTION) { $event->addNewData('amconf_mass_action_product_ids', $dataObj->getProductIds()); } } } return true; }
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; }
/** * Register event data during category save process * * @param Mage_Index_Model_Event $event */ protected function _registerCategoryEvent(Mage_Index_Model_Event $event) { $category = $event->getDataObject(); if (!$category->getInitialSetupFlag() && $category->getLevel() > 1) { if ($category->dataHasChangedFor('is_anchor')) { $event->addNewData('rewrite_category_ids', array($category->getId())); } } return parent::_registerCategoryEvent($event); }
/** * 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; } } }
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; } }
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 _registerEvent(Mage_Index_Model_Event $event) { $event->addNewData(self::EVENT_MATCH_RESULT_KEY, true); $entity = $event->getEntity(); switch ($entity) { case Mage_Core_Model_Store::ENTITY: case Mage_Core_Model_Store_Group::ENTITY: $process = $event->getProcess(); $process->changeStatus(Mage_Index_Model_Process::STATUS_REQUIRE_REINDEX); break; } return $this; }
/** * match whether the reindexing should be fired * @param Mage_Index_Model_Event $event * @return bool */ 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(); $result = true; if ($entity != Mage_Catalog_Model_Product::ENTITY) { return; } $event->addNewData(self::EVENT_MATCH_RESULT_KEY, $result); return $result; }
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; }
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; }
public function matchEvent(Mage_Index_Model_Event $event) { $result = false; $event->addNewData(self::EVENT_MATCH_RESULT_KEY, $result); return $result; }
/** * 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; }
/** * 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; }
/** * Register data required by process in event object * * @param Mage_Index_Model_Event $event */ protected function _registerEvent(Mage_Index_Model_Event $event) { $event->addNewData(self::EVENT_MATCH_RESULT_KEY, true); $entity = $event->getEntity(); if ($entity == Mage_Core_Model_Config_Data::ENTITY || $entity == Mage_Customer_Model_Group::ENTITY) { $process = $event->getProcess(); $process->changeStatus(Mage_Index_Model_Process::STATUS_REQUIRE_REINDEX); } else { if ($entity == Mage_Catalog_Model_Convert_Adapter_Product::ENTITY) { $event->addNewData('catalog_product_price_reindex_all', true); } else { if ($entity == Mage_Catalog_Model_Product::ENTITY) { switch ($event->getType()) { case Mage_Index_Model_Event::TYPE_DELETE: $this->_registerCatalogProductDeleteEvent($event); break; case Mage_Index_Model_Event::TYPE_SAVE: $this->_registerCatalogProductSaveEvent($event); break; case Mage_Index_Model_Event::TYPE_MASS_ACTION: $this->_registerCatalogProductMassActionEvent($event); break; case self::EVENT_TYPE_REINDEX_PRICE: $event->addNewData('id', $event->getDataObject()->getId()); break; } // call product type indexers registerEvent $indexers = $this->_getResource()->getTypeIndexers(); foreach ($indexers as $indexer) { $indexer->registerEvent($event); } } } } }
/** * Register indexer required data inside event object * * @param Mage_Index_Model_Event $event * @return void */ protected function _registerEvent(Mage_Index_Model_Event $event) { $event->addNewData('indexers', $this->getEntityIndexers($event)); }
/** * Register indexer required data inside event object * * @param Mage_Index_Model_Event $event */ protected function _registerEvent(Mage_Index_Model_Event $event) { switch ($event->getType()) { case self::EVENT_TYPE_REINDEX_PRODUCTS: switch ($event->getEntity()) { case self::ENTITY_PRODUCT: $event->addNewData('product', $event->getDataObject()); break; } break; case self::EVENT_TYPE_CLEAN_TARGETRULES: switch ($event->getEntity()) { case self::ENTITY_TARGETRULE: $event->addNewData('params', $event->getDataObject()); break; } break; } }
/** * @param Mana_Seo_Model_UrlIndexer $indexer * @param Mage_Index_Model_Event $event */ public function register($indexer, $event) { if ($event->getEntity() == Mage_Catalog_Model_Category::ENTITY) { $event->addNewData('category_id', $event->getData('data_object')->getId())->addNewData('category_path', $event->getData('data_object')->getPath()); } }
/** * Register indexer required data inside event object * * @param Mage_Index_Model_Event $event */ protected function _registerEvent(Mage_Index_Model_Event $event) { /* @var $object Mana_Db_Model_Entity */ $object = $event->getData('data_object'); $key = $event->getData('entity') . '-' . $object->getId(); if (isset($this->_matchedEvents[$key])) { $event->addNewData('entity_filters', $this->_matchedEvents[$key]->getData('entity_filters'))->addNewData('entity_filter_id', $object->getId()); } }
/** * 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()); } }
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; $reindexData['catalogsearch_product_ids'] = $actionObject->getProductIds(); foreach ($reindexData as $k => $v) { $event->addNewData($k, $v); } break; } return $this; }
/** * 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; }
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()); } }
/** * 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; }
/** * @param Mana_Seo_Model_UrlIndexer $indexer * @param Mage_Index_Model_Event $event */ public function register($indexer, $event) { if ($event->getEntity() == 'cms/page') { $event->addNewData('cms_page_id', $event->getData('data_object')->getId()); } }
/** * Register event data during category save process * * @param Mage_Index_Model_Event $event */ protected function _registerCategoryEvent(Mage_Index_Model_Event $event) { $category = $event->getDataObject(); if (!$category->getInitialSetupFlag() && $category->getLevel() > 1) { if ($category->dataHasChangedFor('url_key') || $category->getIsChangedProductList()) { $event->addNewData('rewrite_category_ids', array($category->getId())); } /** * Check if category has another affected category ids (category move result) */ if ($category->getAffectedCategoryIds()) { $event->addNewData('rewrite_category_ids', $category->getAffectedCategoryIds()); } } }
/** * Register indexer required data inside event object * * @param Mage_Index_Model_Event $event */ protected function _registerEvent(Mage_Index_Model_Event $event) { switch ($event->getType()) { case self::EVENT_TYPE_REINDEX_PRODUCTS: switch ($event->getEntity()) { case self::ENTITY_PRODUCT: $event->addNewData('product_ids', $event->getDataObject()->getId()); break; case self::ENTITY_CATEGORY: $event->addNewData('category_path', $event->getDataObject()->getId()); break; } break; } }