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:  * Attribute add/edit form options tab
 29:  *
 30:  * @category   Mage
 31:  * @package    Mage_Eav
 32:  * @author     Magento Core Team <core@magentocommerce.com>
 33:  */
 34: abstract class Mage_Eav_Block_Adminhtml_Attribute_Edit_Options_Abstract extends Mage_Adminhtml_Block_Widget
 35: {
 36: 
 37:     public function __construct()
 38:     {
 39:         parent::__construct();
 40:         $this->setTemplate('catalog/product/attribute/options.phtml');
 41:     }
 42: 
 43:     /**
 44:      * Preparing layout, adding buttons
 45:      *
 46:      * @return Mage_Eav_Block_Adminhtml_Attribute_Edit_Options_Abstract
 47:      */
 48:     protected function _prepareLayout()
 49:     {
 50:         $this->setChild('delete_button',
 51:             $this->getLayout()->createBlock('adminhtml/widget_button')
 52:                 ->setData(array(
 53:                     'label' => Mage::helper('eav')->__('Delete'),
 54:                     'class' => 'delete delete-option'
 55:                 )));
 56: 
 57:         $this->setChild('add_button',
 58:             $this->getLayout()->createBlock('adminhtml/widget_button')
 59:                 ->setData(array(
 60:                     'label' => Mage::helper('eav')->__('Add Option'),
 61:                     'class' => 'add',
 62:                     'id'    => 'add_new_option_button'
 63:                 )));
 64:         return parent::_prepareLayout();
 65:     }
 66: 
 67:     /**
 68:      * Retrieve HTML of delete button
 69:      *
 70:      * @return string
 71:      */
 72:     public function getDeleteButtonHtml()
 73:     {
 74:         return $this->getChildHtml('delete_button');
 75:     }
 76: 
 77:     /**
 78:      * Retrieve HTML of add button
 79:      *
 80:      * @return string
 81:      */
 82:     public function getAddNewButtonHtml()
 83:     {
 84:         return $this->getChildHtml('add_button');
 85:     }
 86: 
 87:     /**
 88:      * Retrieve stores collection with default store
 89:      *
 90:      * @return Mage_Core_Model_Mysql4_Store_Collection
 91:      */
 92:     public function getStores()
 93:     {
 94:         $stores = $this->getData('stores');
 95:         if (is_null($stores)) {
 96:             $stores = Mage::getModel('core/store')
 97:                 ->getResourceCollection()
 98:                 ->setLoadDefault(true)
 99:                 ->load();
100:             $this->setData('stores', $stores);
101:         }
102:         return $stores;
103:     }
104: 
105:     /**
106:      * Retrieve attribute option values if attribute input type select or multiselect
107:      *
108:      * @return array
109:      */
110:     public function getOptionValues()
111:     {
112:         $attributeType = $this->getAttributeObject()->getFrontendInput();
113:         $defaultValues = $this->getAttributeObject()->getDefaultValue();
114:         if ($attributeType == 'select' || $attributeType == 'multiselect') {
115:             $defaultValues = explode(',', $defaultValues);
116:         } else {
117:             $defaultValues = array();
118:         }
119: 
120:         switch ($attributeType) {
121:             case 'select':
122:                 $inputType = 'radio';
123:                 break;
124:             case 'multiselect':
125:                 $inputType = 'checkbox';
126:                 break;
127:             default:
128:                 $inputType = '';
129:                 break;
130:         }
131: 
132:         $values = $this->getData('option_values');
133:         if (is_null($values)) {
134:             $values = array();
135:             $optionCollection = Mage::getResourceModel('eav/entity_attribute_option_collection')
136:                 ->setAttributeFilter($this->getAttributeObject()->getId())
137:                 ->setPositionOrder('desc', true)
138:                 ->load();
139: 
140:             foreach ($optionCollection as $option) {
141:                 $value = array();
142:                 if (in_array($option->getId(), $defaultValues)) {
143:                     $value['checked'] = 'checked="checked"';
144:                 } else {
145:                     $value['checked'] = '';
146:                 }
147: 
148:                 $value['intype'] = $inputType;
149:                 $value['id'] = $option->getId();
150:                 $value['sort_order'] = $option->getSortOrder();
151:                 foreach ($this->getStores() as $store) {
152:                     $storeValues = $this->getStoreOptionValues($store->getId());
153:                     if (isset($storeValues[$option->getId()])) {
154:                         $value['store'.$store->getId()] = htmlspecialchars($storeValues[$option->getId()]);
155:                     }
156:                     else {
157:                         $value['store'.$store->getId()] = '';
158:                     }
159:                 }
160:                 $values[] = new Varien_Object($value);
161:             }
162:             $this->setData('option_values', $values);
163:         }
164: 
165:         return $values;
166:     }
167: 
168:     /**
169:      * Retrieve frontend labels of attribute for each store
170:      *
171:      * @return array
172:      */
173:     public function getLabelValues()
174:     {
175:         $values = array();
176:         $values[0] = $this->getAttributeObject()->getFrontend()->getLabel();
177:         // it can be array and cause bug
178:         $frontendLabel = $this->getAttributeObject()->getFrontend()->getLabel();
179:         if (is_array($frontendLabel)) {
180:             $frontendLabel = array_shift($frontendLabel);
181:         }
182:         $storeLabels = $this->getAttributeObject()->getStoreLabels();
183:         foreach ($this->getStores() as $store) {
184:             if ($store->getId() != 0) {
185:                 $values[$store->getId()] = isset($storeLabels[$store->getId()]) ? $storeLabels[$store->getId()] : '';
186:             }
187:         }
188:         return $values;
189:     }
190: 
191:     /**
192:      * Retrieve attribute option values for given store id
193:      *
194:      * @param integer $storeId
195:      * @return array
196:      */
197:     public function getStoreOptionValues($storeId)
198:     {
199:         $values = $this->getData('store_option_values_'.$storeId);
200:         if (is_null($values)) {
201:             $values = array();
202:             $valuesCollection = Mage::getResourceModel('eav/entity_attribute_option_collection')
203:                 ->setAttributeFilter($this->getAttributeObject()->getId())
204:                 ->setStoreFilter($storeId, false)
205:                 ->load();
206:             foreach ($valuesCollection as $item) {
207:                 $values[$item->getId()] = $item->getValue();
208:             }
209:             $this->setData('store_option_values_'.$storeId, $values);
210:         }
211:         return $values;
212:     }
213: 
214:     /**
215:      * Retrieve attribute object from registry
216:      *
217:      * @return Mage_Eav_Model_Entity_Attribute_Abstract
218:      */
219:     public function getAttributeObject()
220:     {
221:         return Mage::registry('entity_attribute');
222:     }
223: 
224: }
225: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0