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 Attribute Resource Collection
 30:  *
 31:  * @category    Mage
 32:  * @package     Mage_Eav
 33:  * @author      Magento Core Team <core@magentocommerce.com>
 34:  */
 35: class Mage_Eav_Model_Resource_Form_Attribute_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
 36: {
 37:     /**
 38:      * Current module pathname
 39:      *
 40:      * @var string
 41:      */
 42:     protected $_moduleName = '';
 43: 
 44:     /**
 45:      * Current EAV entity type code
 46:      *
 47:      * @var string
 48:      */
 49:     protected $_entityTypeCode = '';
 50: 
 51:     /**
 52:      * Current store instance
 53:      *
 54:      * @var Mage_Core_Model_Store
 55:      */
 56:     protected $_store;
 57: 
 58:     /**
 59:      * Eav Entity Type instance
 60:      *
 61:      * @var Mage_Eav_Model_Entity_Type
 62:      */
 63:     protected $_entityType;
 64: 
 65:     /**
 66:      * Resource initialization
 67:      *
 68:      * @throws Mage_Core_Exception
 69:      */
 70:     protected function _construct()
 71:     {
 72:         if (empty($this->_moduleName)) {
 73:             Mage::throwException(Mage::helper('eav')->__('Current module pathname is undefined'));
 74:         }
 75:         if (empty($this->_entityTypeCode)) {
 76:             Mage::throwException(Mage::helper('eav')->__('Current module EAV entity is undefined'));
 77:         }
 78:     }
 79: 
 80:     /**
 81:      * Get EAV website table
 82:      *
 83:      * Get table, where website-dependent attribute parameters are stored
 84:      * If realization doesn't demand this functionality, let this function just return null
 85:      *
 86:      * @return string|null
 87:      */
 88:     protected function _getEavWebsiteTable()
 89:     {
 90:         return null;
 91:     }
 92: 
 93:     /**
 94:      * Set current store to collection
 95:      *
 96:      * @param Mage_Core_Model_Store|string|int $store
 97:      * @return Mage_Eav_Model_Resource_Form_Attribute_Collection
 98:      */
 99:     public function setStore($store)
100:     {
101:         $this->_store = Mage::app()->getStore($store);
102:         return $this;
103:     }
104: 
105:     /**
106:      * Return current store instance
107:      *
108:      * @return Mage_Core_Model_Store
109:      */
110:     public function getStore()
111:     {
112:         if ($this->_store === null) {
113:             $this->_store = Mage::app()->getStore();
114:         }
115:         return $this->_store;
116:     }
117: 
118:     /**
119:      * Set entity type instance to collection
120:      *
121:      * @param Mage_Eav_Model_Entity_Type|string|int $entityType
122:      * @return Mage_Eav_Model_Resource_Form_Attribute_Collection
123:      */
124:     public function setEntityType($entityType)
125:     {
126:         $this->_entityType = Mage::getSingleton('eav/config')->getEntityType($entityType);
127:         return $this;
128:     }
129: 
130:     /**
131:      * Return current entity type instance
132:      *
133:      * @return Mage_Eav_Model_Entity_Type
134:      */
135:     public function getEntityType()
136:     {
137:         if ($this->_entityType === null) {
138:             $this->setEntityType($this->_entityTypeCode);
139:         }
140:         return $this->_entityType;
141:     }
142: 
143:     /**
144:      * Add Form Code filter to collection
145:      *
146:      * @param string $code
147:      * @return Mage_Eav_Model_Resource_Form_Attribute_Collection
148:      */
149:     public function addFormCodeFilter($code)
150:     {
151:         return $this->addFieldToFilter('main_table.form_code', $code);
152:     }
153: 
154:     /**
155:      * Set order by attribute sort order
156:      *
157:      * @param string $direction
158:      * @return Mage_Eav_Model_Resource_Form_Attribute_Collection
159:      */
160:     public function setSortOrder($direction = self::SORT_ORDER_ASC)
161:     {
162:         $this->setOrder('ea.is_user_defined', self::SORT_ORDER_ASC);
163:         return $this->setOrder('ca.sort_order', $direction);
164:     }
165: 
166:     /**
167:      * Add joins to select
168:      *
169:      * @return Mage_Eav_Model_Resource_Form_Attribute_Collection
170:      */
171:     protected function _beforeLoad()
172:     {
173:         $select     = $this->getSelect();
174:         $connection = $this->getConnection();
175:         $entityType = $this->getEntityType();
176:         $this->setItemObjectClass($entityType->getAttributeModel());
177: 
178:         $eaColumns  = array();
179:         $caColumns  = array();
180:         $saColumns  = array();
181: 
182:         $eaDescribe = $connection->describeTable($this->getTable('eav/attribute'));
183:         unset($eaDescribe['attribute_id']);
184:         foreach (array_keys($eaDescribe) as $columnName) {
185:             $eaColumns[$columnName] = $columnName;
186:         }
187: 
188:         $select->join(
189:             array('ea' => $this->getTable('eav/attribute')),
190:             'main_table.attribute_id = ea.attribute_id',
191:             $eaColumns
192:         );
193: 
194:         // join additional attribute data table
195:         $additionalTable = $entityType->getAdditionalAttributeTable();
196:         if ($additionalTable) {
197:             $caDescribe = $connection->describeTable($this->getTable($additionalTable));
198:             unset($caDescribe['attribute_id']);
199:             foreach (array_keys($caDescribe) as $columnName) {
200:                 $caColumns[$columnName] = $columnName;
201:             }
202: 
203:             $select->join(
204:                 array('ca' => $this->getTable($additionalTable)),
205:                 'main_table.attribute_id = ca.attribute_id',
206:                 $caColumns
207:             );
208:         }
209: 
210:         // add scope values
211:         if ($this->_getEavWebsiteTable()) {
212:             $saDescribe = $connection->describeTable($this->_getEavWebsiteTable());
213:             unset($saDescribe['attribute_id']);
214:             foreach (array_keys($saDescribe) as $columnName) {
215:                 if ($columnName == 'website_id') {
216:                     $saColumns['scope_website_id'] = $columnName;
217:                 } else {
218:                     if (isset($eaColumns[$columnName])) {
219:                         $code = sprintf('scope_%s', $columnName);
220:                         $expression = $connection->getCheckSql('sa.%s IS NULL', 'ea.%s', 'sa.%s');
221:                         $saColumns[$code] = new Zend_Db_Expr(sprintf($expression,
222:                             $columnName, $columnName, $columnName));
223:                     } elseif (isset($caColumns[$columnName])) {
224:                         $code = sprintf('scope_%s', $columnName);
225:                         $expression = $connection->getCheckSql('sa.%s IS NULL', 'ca.%s', 'sa.%s');
226:                         $saColumns[$code] = new Zend_Db_Expr(sprintf($expression,
227:                             $columnName, $columnName, $columnName));
228:                     }
229:                 }
230:             }
231: 
232:             $store = $this->getStore();
233:             $joinWebsiteExpression = $connection
234:                 ->quoteInto(
235:                     'sa.attribute_id = main_table.attribute_id AND sa.website_id = ?', (int)$store->getWebsiteId()
236:                 );
237:             $select->joinLeft(
238:                 array('sa' => $this->_getEavWebsiteTable()),
239:                 $joinWebsiteExpression,
240:                 $saColumns
241:             );
242:         }
243: 
244: 
245:         // add store attribute label
246:         if ($store->isAdmin()) {
247:             $select->columns(array('store_label' => 'ea.frontend_label'));
248:         } else {
249:             $storeLabelExpr = $connection->getCheckSql('al.value IS NULL', 'ea.frontend_label', 'al.value');
250:             $joinExpression = $connection
251:                 ->quoteInto('al.attribute_id = main_table.attribute_id AND al.store_id = ?', (int)$store->getId());
252:             $select->joinLeft(
253:                 array('al' => $this->getTable('eav/attribute_label')),
254:                 $joinExpression,
255:                 array('store_label' => $storeLabelExpr)
256:             );
257:         }
258: 
259:         // add entity type filter
260:         $select->where('ea.entity_type_id = ?', (int)$entityType->getId());
261: 
262:         return parent::_beforeLoad();
263:     }
264: }
265: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0