/** * Process index data after attribute information was changed * * @param Varien_Event_Observer $observer * @return Mage_CatalogIndex_Model_Observer */ public function processAttributeChangeEvent(Varien_Event_Observer $observer) { /** * @todo add flag to attribute model which will notify what options was changed */ $attribute = $observer->getAttribute(); $tags = array(Mage_Eav_Model_Entity_Attribute::CACHE_TAG . ':' . $attribute->getId()); if ($attribute->getOrigData('is_filterable') != $attribute->getIsFilterable()) { if ($attribute->getIsFilterable() != 0) { $this->_getIndexer()->plainReindex(null, $attribute); } else { $this->_getAggregator()->clearCacheData($tags); } } elseif ($attribute->getIsFilterable()) { $this->_getAggregator()->clearCacheData($tags); } return $this; }
/** * @param Varien_Event_Observer $observer * @return $this */ public function saveAttributeData($observer) { /** @var $connection Varien_Db_Adapter_Pdo_Mysql */ $connection = Mage::getSingleton('core/resource')->getConnection('read'); $table = Mage::getSingleton('core/resource')->getTableName('ecommerceteam_sln_attribute_data'); $attributeId = (int) $observer->getAttribute()->getAttributeId(); $groupId = addslashes($observer->getAttribute()->getData('group_id')); $frontendType = addslashes($observer->getAttribute()->getData('frontend_type')); $comment = $observer->getAttribute()->getData('comment'); $optionsLimit = $observer->getAttribute()->getData('options_limit'); $connection->insertOnDuplicate($table, array('attribute_id' => $attributeId, 'group_id' => $groupId, 'frontend_type' => $frontendType, 'comment' => $comment, 'options_limit' => $optionsLimit)); return $this; }