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 Form Fieldset Resource Model
 30:  *
 31:  * @category    Mage
 32:  * @package     Mage_Eav
 33:  * @author      Magento Core Team <core@magentocommerce.com>
 34:  */
 35: class Mage_Eav_Model_Resource_Form_Fieldset extends Mage_Core_Model_Resource_Db_Abstract
 36: {
 37:     /**
 38:      * Initialize connection and define main table
 39:      */
 40:     protected function _construct()
 41:     {
 42:         $this->_init('eav/form_fieldset', 'fieldset_id');
 43:         $this->addUniqueField(array(
 44:             'field' => array('type_id', 'code'),
 45:             'title' => Mage::helper('eav')->__('Form Fieldset with the same code')
 46:         ));
 47:     }
 48: 
 49:     /**
 50:      * After save (save labels)
 51:      *
 52:      * @param Mage_Eav_Model_Form_Fieldset $object
 53:      * @return Mage_Eav_Model_Resource_Form_Fieldset
 54:      */
 55:     protected function _afterSave(Mage_Core_Model_Abstract $object)
 56:     {
 57:         if ($object->hasLabels()) {
 58:             $new        = $object->getLabels();
 59:             $old        = $this->getLabels($object);
 60: 
 61:             $adapter    = $this->_getWriteAdapter();
 62: 
 63:             $insert     = array_diff(array_keys($new), array_keys($old));
 64:             $delete     = array_diff(array_keys($old), array_keys($new));
 65:             $update     = array();
 66: 
 67:             foreach ($new as $storeId => $label) {
 68:                 if (isset($old[$storeId]) && $old[$storeId] != $label) {
 69:                     $update[$storeId] = $label;
 70:                 } elseif (isset($old[$storeId]) && empty($label)) {
 71:                     $delete[] = $storeId;
 72:                 }
 73:             }
 74: 
 75:             if (!empty($insert)) {
 76:                 $data = array();
 77:                 foreach ($insert as $storeId) {
 78:                     $label = $new[$storeId];
 79:                     if (empty($label)) {
 80:                         continue;
 81:                     }
 82:                     $data[] = array(
 83:                         'fieldset_id'   => (int)$object->getId(),
 84:                         'store_id'      => (int)$storeId,
 85:                         'label'         => $label
 86:                     );
 87:                 }
 88:                 if ($data) {
 89:                     $adapter->insertMultiple($this->getTable('eav/form_fieldset_label'), $data);
 90:                 }
 91:             }
 92: 
 93:             if (!empty($delete)) {
 94:                 $where = array(
 95:                     'fieldset_id = ?' => $object->getId(),
 96:                     'store_id IN(?)' => $delete
 97:                 );
 98:                 $adapter->delete($this->getTable('eav/form_fieldset_label'), $where);
 99:             }
100: 
101:             if (!empty($update)) {
102:                 foreach ($update as $storeId => $label) {
103:                     $bind  = array('label' => $label);
104:                     $where = array(
105:                         'fieldset_id =?' => $object->getId(),
106:                         'store_id =?'    => $storeId
107:                     );
108:                     $adapter->update($this->getTable('eav/form_fieldset_label'), $bind, $where);
109:                 }
110:             }
111:         }
112: 
113:         return parent::_afterSave($object);
114:     }
115: 
116:     /**
117:      * Retrieve fieldset labels for stores
118:      *
119:      * @param Mage_Eav_Model_Form_Fieldset $object
120:      * @return array
121:      */
122:     public function getLabels($object)
123:     {
124:         $objectId = $object->getId();
125:         if (!$objectId) {
126:             return array();
127:         }
128:         $adapter = $this->_getReadAdapter();
129:         $bind    = array(':fieldset_id' => $objectId);
130:         $select  = $adapter->select()
131:             ->from($this->getTable('eav/form_fieldset_label'), array('store_id', 'label'))
132:             ->where('fieldset_id = :fieldset_id');
133: 
134:         return $adapter->fetchPairs($select, $bind);
135:     }
136: 
137:     /**
138:      * Retrieve select object for load object data
139:      *
140:      * @param string $field
141:      * @param mixed $value
142:      * @param Mage_Eav_Model_Form_Fieldset $object
143:      * @return Varien_Db_Select
144:      */
145:     protected function _getLoadSelect($field, $value, $object)
146:     {
147:         $select = parent::_getLoadSelect($field, $value, $object);
148: 
149:         $labelExpr = $select->getAdapter()->getIfNullSql('store_label.label', 'default_label.label');
150: 
151:         $select
152:             ->joinLeft(
153:                 array('default_label' => $this->getTable('eav/form_fieldset_label')),
154:                 $this->getMainTable() . '.fieldset_id = default_label.fieldset_id AND default_label.store_id=0',
155:                 array())
156:             ->joinLeft(
157:                 array('store_label' => $this->getTable('eav/form_fieldset_label')),
158:                 $this->getMainTable() . '.fieldset_id = store_label.fieldset_id AND default_label.store_id='
159:                     . (int)$object->getStoreId(),
160:                 array('label' => $labelExpr)
161:             );
162: 
163:         return $select;
164:     }
165: }
166: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0