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: class Mage_Eav_Model_Entity_Attribute_Source_Table extends Mage_Eav_Model_Entity_Attribute_Source_Abstract
 29: {
 30:     /**
 31:      * Default values for option cache
 32:      *
 33:      * @var array
 34:      */
 35:     protected $_optionsDefault = array();
 36: 
 37:     /**
 38:      * Retrieve Full Option values array
 39:      *
 40:      * @param bool $withEmpty       Add empty option to array
 41:      * @param bool $defaultValues
 42:      * @return array
 43:      */
 44:     public function getAllOptions($withEmpty = true, $defaultValues = false)
 45:     {
 46:         $storeId = $this->getAttribute()->getStoreId();
 47:         if (!is_array($this->_options)) {
 48:             $this->_options = array();
 49:         }
 50:         if (!is_array($this->_optionsDefault)) {
 51:             $this->_optionsDefault = array();
 52:         }
 53:         if (!isset($this->_options[$storeId])) {
 54:             $collection = Mage::getResourceModel('eav/entity_attribute_option_collection')
 55:                 ->setPositionOrder('asc')
 56:                 ->setAttributeFilter($this->getAttribute()->getId())
 57:                 ->setStoreFilter($this->getAttribute()->getStoreId())
 58:                 ->load();
 59:             $this->_options[$storeId]        = $collection->toOptionArray();
 60:             $this->_optionsDefault[$storeId] = $collection->toOptionArray('default_value');
 61:         }
 62:         $options = ($defaultValues ? $this->_optionsDefault[$storeId] : $this->_options[$storeId]);
 63:         if ($withEmpty) {
 64:             array_unshift($options, array('label' => '', 'value' => ''));
 65:         }
 66: 
 67:         return $options;
 68:     }
 69: 
 70:     /**
 71:      * Get a text for option value
 72:      *
 73:      * @param string|integer $value
 74:      * @return string
 75:      */
 76:     public function getOptionText($value)
 77:     {
 78:         $isMultiple = false;
 79:         if (strpos($value, ',')) {
 80:             $isMultiple = true;
 81:             $value = explode(',', $value);
 82:         }
 83: 
 84:         $options = $this->getAllOptions(false);
 85: 
 86:         if ($isMultiple) {
 87:             $values = array();
 88:             foreach ($options as $item) {
 89:                 if (in_array($item['value'], $value)) {
 90:                     $values[] = $item['label'];
 91:                 }
 92:             }
 93:             return $values;
 94:         }
 95: 
 96:         foreach ($options as $item) {
 97:             if ($item['value'] == $value) {
 98:                 return $item['label'];
 99:             }
100:         }
101:         return false;
102:     }
103: 
104:     /**
105:      * Add Value Sort To Collection Select
106:      *
107:      * @param Mage_Eav_Model_Entity_Collection_Abstract $collection
108:      * @param string $dir
109:      *
110:      * @return Mage_Eav_Model_Entity_Attribute_Source_Table
111:      */
112:     public function addValueSortToCollection($collection, $dir = Varien_Db_Select::SQL_ASC)
113:     {
114:         $valueTable1    = $this->getAttribute()->getAttributeCode() . '_t1';
115:         $valueTable2    = $this->getAttribute()->getAttributeCode() . '_t2';
116:         $collection->getSelect()
117:             ->joinLeft(
118:                 array($valueTable1 => $this->getAttribute()->getBackend()->getTable()),
119:                 "e.entity_id={$valueTable1}.entity_id"
120:                 . " AND {$valueTable1}.attribute_id='{$this->getAttribute()->getId()}'"
121:                 . " AND {$valueTable1}.store_id=0",
122:                 array())
123:             ->joinLeft(
124:                 array($valueTable2 => $this->getAttribute()->getBackend()->getTable()),
125:                 "e.entity_id={$valueTable2}.entity_id"
126:                 . " AND {$valueTable2}.attribute_id='{$this->getAttribute()->getId()}'"
127:                 . " AND {$valueTable2}.store_id='{$collection->getStoreId()}'",
128:                 array()
129:             );
130:         $valueExpr = $collection->getSelect()->getAdapter()
131:             ->getCheckSql("{$valueTable2}.value_id > 0", "{$valueTable2}.value", "{$valueTable1}.value");
132: 
133:         Mage::getResourceModel('eav/entity_attribute_option')
134:             ->addOptionValueToCollection($collection, $this->getAttribute(), $valueExpr);
135: 
136:         $collection->getSelect()
137:             ->order("{$this->getAttribute()->getAttributeCode()} {$dir}");
138: 
139:         return $this;
140:     }
141: 
142:     /**
143:      * Retrieve Column(s) for Flat
144:      *
145:      * @return array
146:      */
147:     public function getFlatColums()
148:     {
149:         $columns = array();
150:         $attributeCode = $this->getAttribute()->getAttributeCode();
151:         $isMulti = $this->getAttribute()->getFrontend()->getInputType() == 'multiselect';
152: 
153:         if (Mage::helper('core')->useDbCompatibleMode()) {
154:             $columns[$attributeCode] = array(
155:                 'type'      => $isMulti ? 'varchar(255)' : 'int',
156:                 'unsigned'  => false,
157:                 'is_null'   => true,
158:                 'default'   => null,
159:                 'extra'     => null
160:             );
161:             if (!$isMulti) {
162:                 $columns[$attributeCode . '_value'] = array(
163:                     'type'      => 'varchar(255)',
164:                     'unsigned'  => false,
165:                     'is_null'   => true,
166:                     'default'   => null,
167:                     'extra'     => null
168:                 );
169:             }
170:         } else {
171:             $type = ($isMulti) ? Varien_Db_Ddl_Table::TYPE_TEXT : Varien_Db_Ddl_Table::TYPE_INTEGER;
172:             $columns[$attributeCode] = array(
173:                 'type'      => $type,
174:                 'length'    => $isMulti ? '255' : null,
175:                 'unsigned'  => false,
176:                 'nullable'   => true,
177:                 'default'   => null,
178:                 'extra'     => null,
179:                 'comment'   => $attributeCode . ' column'
180:             );
181:             if (!$isMulti) {
182:                 $columns[$attributeCode . '_value'] = array(
183:                     'type'      => Varien_Db_Ddl_Table::TYPE_TEXT,
184:                     'length'    => 255,
185:                     'unsigned'  => false,
186:                     'nullable'  => true,
187:                     'default'   => null,
188:                     'extra'     => null,
189:                     'comment'   => $attributeCode . ' column'
190:                 );
191:             }
192:         }
193: 
194:         return $columns;
195:     }
196: 
197:     /**
198:      * Retrieve Indexes for Flat
199:      *
200:      * @return array
201:      */
202:     public function getFlatIndexes()
203:     {
204:         $indexes = array();
205: 
206:         $index = sprintf('IDX_%s', strtoupper($this->getAttribute()->getAttributeCode()));
207:         $indexes[$index] = array(
208:             'type'      => 'index',
209:             'fields'    => array($this->getAttribute()->getAttributeCode())
210:         );
211: 
212:         $sortable   = $this->getAttribute()->getUsedForSortBy();
213:         if ($sortable && $this->getAttribute()->getFrontend()->getInputType() != 'multiselect') {
214:             $index = sprintf('IDX_%s_VALUE', strtoupper($this->getAttribute()->getAttributeCode()));
215: 
216:             $indexes[$index] = array(
217:                 'type'      => 'index',
218:                 'fields'    => array($this->getAttribute()->getAttributeCode() . '_value')
219:             );
220:         }
221: 
222:         return $indexes;
223:     }
224: 
225:     /**
226:      * Retrieve Select For Flat Attribute update
227:      *
228:      * @param int $store
229:      * @return Varien_Db_Select|null
230:      */
231:     public function getFlatUpdateSelect($store)
232:     {
233:         return Mage::getResourceModel('eav/entity_attribute_option')
234:             ->getFlatUpdateSelect($this->getAttribute(), $store);
235:     }
236: }
237: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0