Overview

Packages

  • currencysymbol
  • MAbout
  • Mage
    • Admin
    • Adminhtml
    • AdminNotification
    • Api
    • Api2
    • Authorizenet
    • Backup
    • Bundle
    • Captcha
    • Catalog
    • CatalogIndex
    • CatalogInventory
    • CatalogRule
    • CatalogSearch
    • Centinel
    • Checkout
    • Cms
    • Compiler
    • Connect
    • Contacts
    • Core
    • Cron
    • CurrencySymbol
    • Customer
    • Dataflow
    • Directory
    • DirtectPost
    • Downloadable
    • Eav
    • GiftMessage
    • GoogleAnalytics
    • GoogleBase
    • GoogleCheckout
    • ImportExport
    • Index
    • Install
    • Log
    • Media
    • Newsletter
    • Oauth
    • Page
    • PageCache
    • Paygate
    • Payment
    • Paypal
    • PaypalUk
    • Persistent
    • Poll
    • ProductAlert
    • Rating
    • Reports
    • Review
    • Rss
    • Rule
    • Sales
    • SalesRule
    • Sedfriend
    • Sendfriend
    • Shipping
    • Sitemap
    • Tag
    • Tax
    • Usa
    • Weee
    • Widget
    • Wishlist
    • XmlConnect
  • None
  • Phoenix
    • Moneybookers
  • PHP
  • Zend
    • Date
    • Mime
    • XmlRpc

Classes

  • Mage_Catalog_Model_Entity_Product_Attribute_Design_Options_Container
  • Mage_Catalog_Model_Product_Attribute_Source_Inputtype
  • Mage_Eav_Block_Adminhtml_Attribute_Edit_Js
  • Mage_Eav_Block_Adminhtml_Attribute_Edit_Main_Abstract
  • Mage_Eav_Block_Adminhtml_Attribute_Edit_Options_Abstract
  • Mage_Eav_Helper_Data
  • Mage_Eav_Model_Adminhtml_System_Config_Source_Inputtype
  • Mage_Eav_Model_Adminhtml_System_Config_Source_Inputtype_Validator
  • Mage_Eav_Model_Attribute
  • Mage_Eav_Model_Attribute_Data
  • Mage_Eav_Model_Attribute_Data_Abstract
  • Mage_Eav_Model_Attribute_Data_Boolean
  • Mage_Eav_Model_Attribute_Data_Date
  • Mage_Eav_Model_Attribute_Data_File
  • Mage_Eav_Model_Attribute_Data_Hidden
  • Mage_Eav_Model_Attribute_Data_Image
  • Mage_Eav_Model_Attribute_Data_Multiline
  • Mage_Eav_Model_Attribute_Data_Multiselect
  • Mage_Eav_Model_Attribute_Data_Select
  • Mage_Eav_Model_Attribute_Data_Text
  • Mage_Eav_Model_Attribute_Data_Textarea
  • Mage_Eav_Model_Config
  • Mage_Eav_Model_Convert_Adapter_Entity
  • Mage_Eav_Model_Convert_Adapter_Grid
  • Mage_Eav_Model_Convert_Parser_Abstract
  • Mage_Eav_Model_Entity
  • Mage_Eav_Model_Entity_Abstract
  • Mage_Eav_Model_Entity_Attribute
  • Mage_Eav_Model_Entity_Attribute_Abstract
  • Mage_Eav_Model_Entity_Attribute_Backend_Abstract
  • Mage_Eav_Model_Entity_Attribute_Backend_Array
  • Mage_Eav_Model_Entity_Attribute_Backend_Datetime
  • Mage_Eav_Model_Entity_Attribute_Backend_Default
  • Mage_Eav_Model_Entity_Attribute_Backend_Increment
  • Mage_Eav_Model_Entity_Attribute_Backend_Serialized
  • Mage_Eav_Model_Entity_Attribute_Backend_Store
  • Mage_Eav_Model_Entity_Attribute_Backend_Time_Created
  • Mage_Eav_Model_Entity_Attribute_Backend_Time_Updated
  • Mage_Eav_Model_Entity_Attribute_Frontend_Abstract
  • Mage_Eav_Model_Entity_Attribute_Frontend_Datetime
  • Mage_Eav_Model_Entity_Attribute_Frontend_Default
  • Mage_Eav_Model_Entity_Attribute_Group
  • Mage_Eav_Model_Entity_Attribute_Option
  • Mage_Eav_Model_Entity_Attribute_Set
  • Mage_Eav_Model_Entity_Attribute_Source_Abstract
  • Mage_Eav_Model_Entity_Attribute_Source_Boolean
  • Mage_Eav_Model_Entity_Attribute_Source_Config
  • Mage_Eav_Model_Entity_Attribute_Source_Store
  • Mage_Eav_Model_Entity_Attribute_Source_Table
  • Mage_Eav_Model_Entity_Collection
  • Mage_Eav_Model_Entity_Collection_Abstract
  • Mage_Eav_Model_Entity_Increment_Abstract
  • Mage_Eav_Model_Entity_Increment_Alphanum
  • Mage_Eav_Model_Entity_Increment_Numeric
  • Mage_Eav_Model_Entity_Setup
  • Mage_Eav_Model_Entity_Store
  • Mage_Eav_Model_Entity_Type
  • Mage_Eav_Model_Form
  • Mage_Eav_Model_Form_Element
  • Mage_Eav_Model_Form_Fieldset
  • Mage_Eav_Model_Form_Type
  • Mage_Eav_Model_Mysql4_Config
  • Mage_Eav_Model_Mysql4_Entity_Attribute
  • Mage_Eav_Model_Mysql4_Entity_Attribute_Collection
  • Mage_Eav_Model_Mysql4_Entity_Attribute_Group
  • Mage_Eav_Model_Mysql4_Entity_Attribute_Group_Collection
  • Mage_Eav_Model_Mysql4_Entity_Attribute_Option
  • Mage_Eav_Model_Mysql4_Entity_Attribute_Option_Collection
  • Mage_Eav_Model_Mysql4_Entity_Attribute_Set
  • Mage_Eav_Model_Mysql4_Entity_Attribute_Set_Collection
  • Mage_Eav_Model_Mysql4_Entity_Store
  • Mage_Eav_Model_Mysql4_Entity_Type
  • Mage_Eav_Model_Mysql4_Entity_Type_Collection
  • Mage_Eav_Model_Mysql4_Form_Element
  • Mage_Eav_Model_Mysql4_Form_Element_Collection
  • Mage_Eav_Model_Mysql4_Form_Fieldset
  • Mage_Eav_Model_Mysql4_Form_Fieldset_Collection
  • Mage_Eav_Model_Mysql4_Form_Type
  • Mage_Eav_Model_Mysql4_Form_Type_Collection
  • Mage_Eav_Model_Resource_Attribute
  • Mage_Eav_Model_Resource_Attribute_Collection
  • Mage_Eav_Model_Resource_Config
  • Mage_Eav_Model_Resource_Entity_Attribute
  • Mage_Eav_Model_Resource_Entity_Attribute_Collection
  • Mage_Eav_Model_Resource_Entity_Attribute_Group
  • Mage_Eav_Model_Resource_Entity_Attribute_Group_Collection
  • Mage_Eav_Model_Resource_Entity_Attribute_Option
  • Mage_Eav_Model_Resource_Entity_Attribute_Option_Collection
  • Mage_Eav_Model_Resource_Entity_Attribute_Set
  • Mage_Eav_Model_Resource_Entity_Attribute_Set_Collection
  • Mage_Eav_Model_Resource_Entity_Store
  • Mage_Eav_Model_Resource_Entity_Type
  • Mage_Eav_Model_Resource_Entity_Type_Collection
  • Mage_Eav_Model_Resource_Form_Attribute
  • Mage_Eav_Model_Resource_Form_Attribute_Collection
  • Mage_Eav_Model_Resource_Form_Element
  • Mage_Eav_Model_Resource_Form_Element_Collection
  • Mage_Eav_Model_Resource_Form_Fieldset
  • Mage_Eav_Model_Resource_Form_Fieldset_Collection
  • Mage_Eav_Model_Resource_Form_Type
  • Mage_Eav_Model_Resource_Form_Type_Collection
  • Mage_Eav_Model_Resource_Helper_Mysql4

Interfaces

  • Mage_Eav_Model_Entity_Attribute_Backend_Interface
  • Mage_Eav_Model_Entity_Attribute_Frontend_Interface
  • Mage_Eav_Model_Entity_Attribute_Interface
  • Mage_Eav_Model_Entity_Attribute_Source_Interface
  • Mage_Eav_Model_Entity_Increment_Interface
  • Mage_Eav_Model_Entity_Interface

Exceptions

  • Mage_Eav_Exception
  • Mage_Eav_Model_Entity_Attribute_Exception
  • Overview
  • Package
  • Class
  • Tree
  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_Eav
 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: /**
 29:  * EAV attribute resource model (Using Forms)
 30:  *
 31:  * @category    Mage
 32:  * @package     Mage_Eav
 33:  * @author      Magento Core Team <core@magentocommerce.com>
 34:  */
 35: abstract class Mage_Eav_Model_Resource_Attribute extends Mage_Eav_Model_Resource_Entity_Attribute
 36: {
 37:     /**
 38:      * Get EAV website table
 39:      *
 40:      * Get table, where website-dependent attribute parameters are stored
 41:      * If realization doesn't demand this functionality, let this function just return null
 42:      *
 43:      * @return string|null
 44:      */
 45:     abstract protected function _getEavWebsiteTable();
 46: 
 47:     /**
 48:      * Get Form attribute table
 49:      *
 50:      * Get table, where dependency between form name and attribute ids are stored
 51:      *
 52:      * @return string|null
 53:      */
 54:     abstract protected function _getFormAttributeTable();
 55: 
 56:     /**
 57:      * Perform actions before object save
 58:      *
 59:      * @param Mage_Core_Model_Abstract $object
 60:      * @return Mage_Eav_Model_Resource_Attribute
 61:      */
 62:     protected function _beforeSave(Mage_Core_Model_Abstract $object)
 63:     {
 64:         $validateRules = $object->getData('validate_rules');
 65:         if (is_array($validateRules)) {
 66:             $object->setData('validate_rules', serialize($validateRules));
 67:         }
 68:         return parent::_beforeSave($object);
 69:     }
 70: 
 71:     /**
 72:      * Retrieve select object for load object data
 73:      *
 74:      * @param string $field
 75:      * @param mixed $value
 76:      * @param Mage_Core_Model_Abstract $object
 77:      * @return Varien_Db_Select
 78:      */
 79:     protected function _getLoadSelect($field, $value, $object)
 80:     {
 81:         $select     = parent::_getLoadSelect($field, $value, $object);
 82:         $websiteId  = (int)$object->getWebsite()->getId();
 83:         if ($websiteId) {
 84:             $adapter    = $this->_getReadAdapter();
 85:             $columns    = array();
 86:             $scopeTable = $this->_getEavWebsiteTable();
 87:             $describe   = $adapter->describeTable($scopeTable);
 88:             unset($describe['attribute_id']);
 89:             foreach (array_keys($describe) as $columnName) {
 90:                 $columns['scope_' . $columnName] = $columnName;
 91:             }
 92:             $conditionSql = $adapter->quoteInto(
 93:                 $this->getMainTable() . '.attribute_id = scope_table.attribute_id AND scope_table.website_id =?',
 94:                 $websiteId);
 95:             $select->joinLeft(
 96:                 array('scope_table' => $scopeTable),
 97:                 $conditionSql,
 98:                 $columns
 99:             );
100:         }
101: 
102:         return $select;
103:     }
104: 
105:     /**
106:      * Save attribute/form relations after attribute save
107:      *
108:      * @param Mage_Core_Model_Abstract $object
109:      * @return Mage_Eav_Model_Resource_Attribute
110:      */
111:     protected function _afterSave(Mage_Core_Model_Abstract $object)
112:     {
113:         $forms      = $object->getData('used_in_forms');
114:         $adapter    = $this->_getWriteAdapter();
115:         if (is_array($forms)) {
116:             $where = array('attribute_id=?' => $object->getId());
117:             $adapter->delete($this->_getFormAttributeTable(), $where);
118: 
119:             $data = array();
120:             foreach ($forms as $formCode) {
121:                 $data[] = array(
122:                     'form_code'     => $formCode,
123:                     'attribute_id'  => (int)$object->getId()
124:                 );
125:             }
126: 
127:             if ($data) {
128:                 $adapter->insertMultiple($this->_getFormAttributeTable(), $data);
129:             }
130:         }
131: 
132:         // update sort order
133:         if (!$object->isObjectNew() && $object->dataHasChangedFor('sort_order')) {
134:             $data  = array('sort_order' => $object->getSortOrder());
135:             $where = array('attribute_id=?' => (int)$object->getId());
136:             $adapter->update($this->getTable('eav/entity_attribute'), $data, $where);
137:         }
138: 
139:         // save scope attributes
140:         $websiteId = (int)$object->getWebsite()->getId();
141:         if ($websiteId) {
142:             $table      = $this->_getEavWebsiteTable();
143:             $describe   = $this->_getReadAdapter()->describeTable($table);
144:             $data       = array();
145:             if (!$object->getScopeWebsiteId() || $object->getScopeWebsiteId() != $websiteId) {
146:                 $data = $this->getScopeValues($object);
147:             }
148: 
149:             $data['attribute_id']   = (int)$object->getId();
150:             $data['website_id']     = (int)$websiteId;
151:             unset($describe['attribute_id']);
152:             unset($describe['website_id']);
153: 
154:             $updateColumns = array();
155:             foreach (array_keys($describe) as $columnName) {
156:                 $data[$columnName] = $object->getData('scope_' . $columnName);
157:                 $updateColumns[]   = $columnName;
158:             }
159: 
160:             $adapter->insertOnDuplicate($table, $data, $updateColumns);
161:         }
162: 
163:         return parent::_afterSave($object);
164:     }
165: 
166:     /**
167:      * Return scope values for attribute and website
168:      *
169:      * @param Mage_Eav_Model_Attribute $object
170:      * @return array
171:      */
172:     public function getScopeValues(Mage_Eav_Model_Attribute $object)
173:     {
174:         $adapter = $this->_getReadAdapter();
175:         $bind    = array(
176:             'attribute_id' => (int)$object->getId(),
177:             'website_id'   => (int)$object->getWebsite()->getId()
178:         );
179:         $select = $adapter->select()
180:             ->from($this->_getEavWebsiteTable())
181:             ->where('attribute_id = :attribute_id')
182:             ->where('website_id = :website_id')
183:             ->limit(1);
184:         $result = $adapter->fetchRow($select, $bind);
185: 
186:         if (!$result) {
187:             $result = array();
188:         }
189: 
190:         return $result;
191:     }
192: 
193:     /**
194:      * Return forms in which the attribute
195:      *
196:      * @param Mage_Core_Model_Abstract $object
197:      * @return array
198:      */
199:     public function getUsedInForms(Mage_Core_Model_Abstract $object)
200:     {
201:         $adapter = $this->_getReadAdapter();
202:         $bind    = array('attribute_id' => (int)$object->getId());
203:         $select  = $adapter->select()
204:             ->from($this->_getFormAttributeTable(), 'form_code')
205:             ->where('attribute_id = :attribute_id');
206: 
207:         return $adapter->fetchCol($select, $bind);
208:     }
209: }
210: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0