本文整理汇总了PHP中Mage_Index_Model_Event类的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Index_Model_Event类的具体用法?PHP Mage_Index_Model_Event怎么用?PHP Mage_Index_Model_Event使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Mage_Index_Model_Event类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: processEvent
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;
}
}
}
开发者ID:kevinrademan,项目名称:Magento-Solr,代码行数:28,代码来源:Cms.php
示例2: _processEvent
/**
* 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);
}
}
开发者ID:manueltoniato,项目名称:smile-magento-elasticsearch,代码行数:14,代码来源:Position.php
示例3: processEvent
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;
}
}
}
开发者ID:kevinrademan,项目名称:Magento-Solr,代码行数:26,代码来源:Product.php
示例4: catalogProductSave
/**
* Modified to pull in all sibling associated products' tier prices and
* to reindex child tier prices when a parent is saved.
*
* Process product save.
* Method is responsible for index support
* when product was saved and changed attribute(s) has an effect on price.
*
* @param Mage_Index_Model_Event $event
* @return Mage_Catalog_Model_Resource_Product_Indexer_Price
*/
public function catalogProductSave(Mage_Index_Model_Event $event)
{
$productId = $event->getEntityPk();
$data = $event->getNewData();
/**
* Check if price attribute values were updated
*/
if (!isset($data['reindex_price'])) {
return $this;
}
$this->clearTemporaryIndexTable();
$this->_prepareWebsiteDateTable();
$indexer = $this->_getIndexer($data['product_type_id']);
$processIds = array($productId);
if ($indexer->getIsComposite()) {
if ($this->getProductTypeById($productId) == 'configurable') {
$children = $this->getChildIdsByParent($productId);
$processIds = array_merge($processIds, array_keys($children));
//Ignore tier and group price data for actual configurable product
$tierPriceIds = array_keys($children);
} else {
$tierPriceIds = $productId;
}
$this->_copyRelationIndexData($productId);
$this->_prepareTierPriceIndex($tierPriceIds);
$this->_prepareGroupPriceIndex($tierPriceIds);
$indexer->reindexEntity($productId);
} else {
$parentIds = $this->getProductParentsByChild($productId);
if ($parentIds) {
$processIds = array_merge($processIds, array_keys($parentIds));
$siblingIds = array();
foreach (array_keys($parentIds) as $parentId) {
$childIds = $this->getChildIdsByParent($parentId);
$siblingIds = array_merge($siblingIds, array_keys($childIds));
}
if (count($siblingIds) > 0) {
$processIds = array_unique(array_merge($processIds, $siblingIds));
}
$this->_copyRelationIndexData(array_keys($parentIds), $productId);
$this->_prepareTierPriceIndex($processIds);
$this->_prepareGroupPriceIndex($processIds);
$indexer->reindexEntity($productId);
$parentByType = array();
foreach ($parentIds as $parentId => $parentType) {
$parentByType[$parentType][$parentId] = $parentId;
}
foreach ($parentByType as $parentType => $entityIds) {
$this->_getIndexer($parentType)->reindexEntity($entityIds);
}
} else {
$this->_prepareTierPriceIndex($productId);
$this->_prepareGroupPriceIndex($productId);
$indexer->reindexEntity($productId);
}
}
$this->_copyIndexDataToMainTable($processIds);
return $this;
}
开发者ID:Emulator000,项目名称:magento-configurable-simple,代码行数:70,代码来源:Price.php
示例5: CmsPageSave
/**
* 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);
}
}
开发者ID:VadzimBelski-ScienceSoft,项目名称:magento-MagSolr,代码行数:13,代码来源:Cms.php
示例6: _processEvent
/**
* 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);
}
}
}
开发者ID:manueltoniato,项目名称:smile-magento-elasticsearch,代码行数:16,代码来源:Position.php
示例7: _processEvent
/**
* 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.'));
}
}
}
开发者ID:kevinrademan,项目名称:Magento-Solr,代码行数:58,代码来源:Indexer.php
示例8: registerCatalogProductEvent
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;
}
}
开发者ID:brethash,项目名称:magento-MagSolr,代码行数:12,代码来源:Catalog.php
示例9: _registerProductEvent
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()));
}
}
开发者ID:xiaoguizhidao,项目名称:blingjewelry-prod,代码行数:12,代码来源:Url.php
示例10: _registerEvent
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;
}
开发者ID:santhosh400,项目名称:ecart,代码行数:13,代码来源:Url.php
示例11: _processEvent
protected function _processEvent(Mage_Index_Model_Event $event)
{
$data = $event->getNewData();
if (!empty($data['udreindex_product_ids'])) {
$this->_getResource()->reindexProducts($data['udreindex_product_ids']);
}
if (!empty($data['udreindex_vendor_ids'])) {
$this->_getResource()->reindexVendors($data['udreindex_vendor_ids']);
}
if (empty($data['catalog_product_price_skip_call_event_handler'])) {
$this->callEventHandler($event);
}
}
开发者ID:xiaoguizhidao,项目名称:magento,代码行数:13,代码来源:VendorProductAssoc.php
示例12: _processEvent
protected function _processEvent(Mage_Index_Model_Event $event)
{
Varien_Profiler::start(__METHOD__);
$data = $event->getNewData();
if (isset($data[self::EVENT_PRODUCT_IDS_KEY]) && is_array($data[self::EVENT_PRODUCT_IDS_KEY])) {
$this->_startUpdate();
foreach ($data[self::EVENT_PRODUCT_IDS_KEY] as $productId) {
$this->_updateProduct($productId);
}
$this->_finishUpdate();
}
Varien_Profiler::stop(__METHOD__);
}
开发者ID:mngr777,项目名称:mage-alsobuy,代码行数:13,代码来源:Similarity.php
示例13: matchEvent
/**
* 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;
}
开发者ID:blackbirdtech,项目名称:merlin-magento,代码行数:19,代码来源:Merlinindexer.php
示例14: register
/**
* @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);
}
}
}
开发者ID:xiaoguizhidao,项目名称:cupboardglasspipes.ecomitize.com,代码行数:19,代码来源:AttributeUrlIndexer.php
示例15: _processEvent
protected function _processEvent(Mage_Index_Model_Event $event)
{
$data = $event->getNewData();
if (!empty($data['amconf_update_product_id'])) {
$this->doSomethingOnUpdateEvent($data['amconf_update_product_id']);
} else {
if (!empty($data['amconf_delete_product_id'])) {
$this->doSomethingOnDeleteEvent($data['amconf_delete_product_id']);
} else {
if (!empty($data['amconf_mass_action_product_ids'])) {
$this->doSomethingOnMassActionEvent($data['amconf_mass_action_product_ids']);
}
}
}
}
开发者ID:Eximagen,项目名称:BulletMagento,代码行数:15,代码来源:Super.php
示例16: _processEvent
/**
* 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;
}
开发者ID:Cotya,项目名称:EcomDev_UrlRewrite,代码行数:23,代码来源:Indexer.php
示例17: _registerCatalogProductMassActionEvent
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;
}
开发者ID:buttasg,项目名称:cowgirlk,代码行数:19,代码来源:Price.php
示例18: _processEvent
protected function _processEvent(Mage_Index_Model_Event $event)
{
if (!$this->config->getApplicationID() || !$this->config->getAPIKey() || !$this->config->getSearchOnlyAPIKey()) {
if (self::$credential_error === false) {
/** @var Mage_Adminhtml_Model_Session $session */
$session = Mage::getSingleton('adminhtml/session');
$session->addError('Algolia indexing failed: You need to configure your Algolia credentials in System > Configuration > Algolia Search.');
self::$credential_error = true;
}
return;
}
$data = $event->getNewData();
/*
* Reindex all products and all categories and update index settings
*/
if (!empty($data['algoliasearch_reindex_all'])) {
$process = $event->getProcess();
$process->changeStatus(Mage_Index_Model_Process::STATUS_REQUIRE_REINDEX);
} else {
/*
* Clear indexer for the deleted category including all children categories and update index for the related products.
*/
if (!empty($data['catalogsearch_delete_category_id'])) {
$categoryIds = $data['catalogsearch_delete_category_id'];
$this->engine->removeCategories(null, $categoryIds);
/*
* Change indexer status as need to reindex related products to update the list of categories.
* It's low priority so no need to automatically reindex all related products after deleting each category.
* Do not reindex all if affected products are given or product count is not indexed.
*/
if (!isset($data['catalogsearch_update_product_id'])) {
$process = $event->getProcess();
$process->changeStatus(Mage_Index_Model_Process::STATUS_REQUIRE_REINDEX);
}
}
}
/*
* Reindex categories.
* Category products are tracked separately. The specified categories are active. See _registerCatalogCategoryEvent().
*/
if (!empty($data['catalogsearch_update_category_id'])) {
$this->reindexSpecificCategories($data['catalogsearch_update_category_id']);
}
/*
* If we have added any new products to a category then we need to
* update these products in Algolia indices.
*/
if (!empty($data['catalogsearch_update_product_id'])) {
$this->reindexSpecificProducts($data['catalogsearch_update_product_id']);
}
}
开发者ID:algolia,项目名称:algoliasearch-magento,代码行数:51,代码来源:Algoliacategories.php
示例19: testCatalogProductSaveAfterMassAction
/**
* @test
*/
public function testCatalogProductSaveAfterMassAction()
{
$this->_fpc->save('product1', 'product1_cache_id', array(sha1('product_1')));
$this->_fpc->save('product2', 'product2_cache_id', array(sha1('product_2')));
$this->_fpc->save('product3', 'product3_cache_id', array(sha1('product_3')));
$event = new Mage_Index_Model_Event();
$productAction = new Mage_Catalog_Model_Product_Action();
$productAction->setProductIds(array(2, 3));
$event->setType('mass_action');
$event->setEntity('catalog_product');
$event->setDataObject($productAction);
Mage::dispatchEvent('model_save_after', array('object' => $event));
$this->assertEquals('product1', $this->_fpc->load('product1_cache_id'));
$this->assertFalse($this->_fpc->load('product2_cache_id'));
$this->assertFalse($this->_fpc->load('product3_cache_id'));
}
开发者ID:AndreKlang,项目名称:Lesti_Fpc,代码行数:19,代码来源:Save.php
示例20: register
/**
* @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);
}
}
}
开发者ID:xiaoguizhidao,项目名称:cupboardglasspipes.ecomitize.com,代码行数:18,代码来源:CategoryParameter.php
注:本文中的Mage_Index_Model_Event类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论