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_Catalog
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: /**
28: * Product attribute extension with event dispatching
29: *
30: * @method Mage_Catalog_Model_Resource_Attribute _getResource()
31: * @method Mage_Catalog_Model_Resource_Attribute getResource()
32: * @method string getFrontendInputRenderer()
33: * @method Mage_Catalog_Model_Entity_Attribute setFrontendInputRenderer(string $value)
34: * @method int setIsGlobal(int $value)
35: * @method int getIsVisible()
36: * @method int setIsVisible(int $value)
37: * @method int getIsSearchable()
38: * @method Mage_Catalog_Model_Entity_Attribute setIsSearchable(int $value)
39: * @method int getSearchWeight()
40: * @method Mage_Catalog_Model_Entity_Attribute setSearchWeight(int $value)
41: * @method int getIsFilterable()
42: * @method Mage_Catalog_Model_Entity_Attribute setIsFilterable(int $value)
43: * @method int getIsComparable()
44: * @method Mage_Catalog_Model_Entity_Attribute setIsComparable(int $value)
45: * @method Mage_Catalog_Model_Entity_Attribute setIsVisibleOnFront(int $value)
46: * @method int getIsHtmlAllowedOnFront()
47: * @method Mage_Catalog_Model_Entity_Attribute setIsHtmlAllowedOnFront(int $value)
48: * @method int getIsUsedForPriceRules()
49: * @method Mage_Catalog_Model_Entity_Attribute setIsUsedForPriceRules(int $value)
50: * @method int getIsFilterableInSearch()
51: * @method Mage_Catalog_Model_Entity_Attribute setIsFilterableInSearch(int $value)
52: * @method int getUsedInProductListing()
53: * @method Mage_Catalog_Model_Entity_Attribute setUsedInProductListing(int $value)
54: * @method int getUsedForSortBy()
55: * @method Mage_Catalog_Model_Entity_Attribute setUsedForSortBy(int $value)
56: * @method int getIsConfigurable()
57: * @method Mage_Catalog_Model_Entity_Attribute setIsConfigurable(int $value)
58: * @method string getApplyTo()
59: * @method Mage_Catalog_Model_Entity_Attribute setApplyTo(string $value)
60: * @method int getIsVisibleInAdvancedSearch()
61: * @method Mage_Catalog_Model_Entity_Attribute setIsVisibleInAdvancedSearch(int $value)
62: * @method int getPosition()
63: * @method Mage_Catalog_Model_Entity_Attribute setPosition(int $value)
64: * @method int getIsWysiwygEnabled()
65: * @method Mage_Catalog_Model_Entity_Attribute setIsWysiwygEnabled(int $value)
66: * @method int getIsUsedForPromoRules()
67: * @method Mage_Catalog_Model_Entity_Attribute setIsUsedForPromoRules(int $value)
68: *
69: * @category Mage
70: * @package Mage_Catalog
71: * @author Magento Core Team <core@magentocommerce.com>
72: */
73: class Mage_Catalog_Model_Entity_Attribute extends Mage_Eav_Model_Entity_Attribute
74: {
75: protected $_eventPrefix = 'catalog_entity_attribute';
76: protected $_eventObject = 'attribute';
77: const MODULE_NAME = 'Mage_Catalog';
78:
79: /**
80: * Processing object before save data
81: *
82: * @return Mage_Core_Model_Abstract
83: */
84: protected function _beforeSave()
85: {
86: if ($this->_getResource()->isUsedBySuperProducts($this)) {
87: throw Mage::exception('Mage_Eav', Mage::helper('eav')->__('This attribute is used in configurable products'));
88: }
89: $this->setData('modulePrefix', self::MODULE_NAME);
90: return parent::_beforeSave();
91: }
92:
93: /**
94: * Processing object after save data
95: *
96: * @return Mage_Core_Model_Abstract
97: */
98: protected function _afterSave()
99: {
100: /**
101: * Fix saving attribute in admin
102: */
103: Mage::getSingleton('eav/config')->clear();
104: return parent::_afterSave();
105: }
106: }
107: