1: <?php
2: /**
3: * Magento
4: *
5: * NOTICE OF LICENSE
6: *
7: * This source file is subject to the Open Software License (OSL 3.0)
8: * that is bundled with this package in the file LICENSE.txt.
9: * It is also available through the world-wide-web at this URL:
10: * http://opensource.org/licenses/osl-3.0.php
11: * If you did not receive a copy of the license and are unable to
12: * obtain it through the world-wide-web, please send an email
13: * to license@magentocommerce.com so we can send you a copy immediately.
14: *
15: * DISCLAIMER
16: *
17: * Do not edit or add to this file if you wish to upgrade Magento to newer
18: * versions in the future. If you wish to customize Magento for your
19: * needs please refer to http://www.magentocommerce.com for more information.
20: *
21: * @category Mage
22: * @package Mage_Index
23: * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24: * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25: */
26:
27: class Mage_Index_Model_Observer
28: {
29: /**
30: * Indexer model
31: *
32: * @var Mage_Index_Model_Indexer
33: */
34: protected $_indexer;
35:
36: public function __construct()
37: {
38: $this->_indexer = Mage::getSingleton('index/indexer');
39: }
40:
41: /**
42: * Store after commit observer. Process store related indexes
43: *
44: * @param Varien_Event_Observer $observer
45: */
46: public function processStoreSave(Varien_Event_Observer $observer)
47: {
48: $store = $observer->getEvent()->getStore();
49: $this->_indexer->processEntityAction(
50: $store,
51: Mage_Core_Model_Store::ENTITY,
52: Mage_Index_Model_Event::TYPE_SAVE
53: );
54: }
55:
56: /**
57: * Store group after commit observer. Process store group related indexes
58: *
59: * @param Varien_Event_Observer $observer
60: */
61: public function processStoreGroupSave(Varien_Event_Observer $observer)
62: {
63: $storeGroup = $observer->getEvent()->getStoreGroup();
64: $this->_indexer->processEntityAction(
65: $storeGroup,
66: Mage_Core_Model_Store_Group::ENTITY,
67: Mage_Index_Model_Event::TYPE_SAVE
68: );
69: }
70:
71: /**
72: * Website save after commit observer. Process website related indexes
73: *
74: * @param Varien_Event_Observer $observer
75: */
76: public function processWebsiteSave(Varien_Event_Observer $observer)
77: {
78: $website = $observer->getEvent()->getWebsite();
79: $this->_indexer->processEntityAction(
80: $website,
81: Mage_Core_Model_Website::ENTITY,
82: Mage_Index_Model_Event::TYPE_SAVE
83: );
84: }
85:
86: /**
87: * Store after commit observer. Process store related indexes
88: *
89: * @param Varien_Event_Observer $observer
90: */
91: public function processStoreDelete(Varien_Event_Observer $observer)
92: {
93: $store = $observer->getEvent()->getStore();
94: $this->_indexer->processEntityAction(
95: $store,
96: Mage_Core_Model_Store::ENTITY,
97: Mage_Index_Model_Event::TYPE_DELETE
98: );
99: }
100:
101: /**
102: * Store group after commit observer. Process store group related indexes
103: *
104: * @param Varien_Event_Observer $observer
105: */
106: public function processStoreGroupDelete(Varien_Event_Observer $observer)
107: {
108: $storeGroup = $observer->getEvent()->getStoreGroup();
109: $this->_indexer->processEntityAction(
110: $storeGroup,
111: Mage_Core_Model_Store_Group::ENTITY,
112: Mage_Index_Model_Event::TYPE_DELETE
113: );
114: }
115:
116: /**
117: * Website save after commit observer. Process website related indexes
118: *
119: * @param Varien_Event_Observer $observer
120: */
121: public function processWebsiteDelete(Varien_Event_Observer $observer)
122: {
123: $website = $observer->getEvent()->getWebsite();
124: $this->_indexer->processEntityAction(
125: $website,
126: Mage_Core_Model_Website::ENTITY,
127: Mage_Index_Model_Event::TYPE_DELETE
128: );
129: }
130:
131: /**
132: * Config data after commit observer.
133: *
134: * @param Varien_Event_Observer $observer
135: */
136: public function processConfigDataSave(Varien_Event_Observer $observer)
137: {
138: $configData = $observer->getEvent()->getConfigData();
139: $this->_indexer->processEntityAction(
140: $configData,
141: Mage_Core_Model_Config_Data::ENTITY,
142: Mage_Index_Model_Event::TYPE_SAVE
143: );
144: }
145:
146: }
147: