Mage_Eav_Model_Entity_Type Class Reference

Inheritance diagram for Mage_Eav_Model_Entity_Type:

Mage_Core_Model_Abstract Varien_Object

List of all members.

Public Member Functions

 loadByCode ($code)
 getAttributeCollection ($setId=null)
 getAttributeSetCollection ()
 fetchNewIncrementId ($storeId=null)
 getEntityIdField ()
 getEntityTable ()
 getValueTablePrefix ()
 getDefaultAttributeSetId ()
 getEntityTypeId ()
 getEntityTypeCode ()
 getAttributeCodes ()
 getAttributeModel ()
 getEntity ()

Protected Member Functions

 _construct ()
 _getAttributeCollection ()

Protected Attributes

 $_attributes
 $_attributesBySet = array()
 $_sets


Detailed Description

Definition at line 35 of file Type.php.


Member Function Documentation

_construct (  )  [protected]

Enter description here...

Reimplemented from Varien_Object.

Definition at line 63 of file Type.php.

00064     {
00065         $this->_init('eav/entity_type');
00066     }

_getAttributeCollection (  )  [protected]

Enter description here...

Returns:
Mage_Eav_Model_Mysql4_Entity_Attribute_Collection

Definition at line 112 of file Type.php.

00113     {
00114         $collection = Mage::getModel('eav/entity_attribute')->getCollection();
00115         if ($objectsModel = $this->getAttributeModel()) {
00116             $collection->setModel($objectsModel);
00117         }
00118         return $collection;
00119     }

fetchNewIncrementId ( storeId = null  ) 

Enter description here...

Parameters:
int $storeId
Returns:
string

store_id null we can have for entity from removed store

do read lock on eav/entity_store to solve potential timing issues (most probably already done by beginTransaction of entity save)

Definition at line 141 of file Type.php.

00142     {
00143         if (!$this->getIncrementModel()) {
00144             return false;
00145         }
00146 
00147         if (!$this->getIncrementPerStore()) {
00148             $storeId = 0;
00149         }
00150         elseif (is_null($storeId)) {
00151             /**
00152              * store_id null we can have for entity from removed store
00153              */
00154             $storeId = 0;
00155             //throw Mage::exception('Mage_Eav', Mage::helper('eav')->__('Valid store_id is expected!'));
00156         }
00157 
00158         $entityStoreConfig = Mage::getModel('eav/entity_store')
00159             ->loadByEntityStore($this->getId(), $storeId);
00160 
00161         if (!$entityStoreConfig->getId()) {
00162             $entityStoreConfig
00163                 ->setEntityTypeId($this->getId())
00164                 ->setStoreId($storeId)
00165                 ->setIncrementPrefix($storeId)
00166                 ->save();
00167         }
00168 
00169         $incrementInstance = Mage::getModel($this->getIncrementModel())
00170             ->setPrefix($entityStoreConfig->getIncrementPrefix())
00171             ->setPadLength($this->getIncrementPadLength())
00172             ->setPadChar($this->getIncrementPadChar())
00173             ->setLastId($entityStoreConfig->getIncrementLastId())
00174             ->setEntityTypeId($entityStoreConfig->getEntityTypeId())
00175             ->setStoreId($entityStoreConfig->getStoreId());
00176 
00177         /**
00178          * do read lock on eav/entity_store to solve potential timing issues
00179          * (most probably already done by beginTransaction of entity save)
00180          */
00181         $incrementId = $incrementInstance->getNextId();
00182         $entityStoreConfig->setIncrementLastId($incrementId);
00183         $entityStoreConfig->save();
00184 
00185         return $incrementId;
00186     }

getAttributeCodes (  ) 

Definition at line 246 of file Type.php.

00247     {
00248         return isset($this->_data['attribute_codes']) ? $this->_data['attribute_codes'] : null;
00249     }

getAttributeCollection ( setId = null  ) 

Retrieve entity type attributes collection

Parameters:
int $setId
Returns:
Mage_Eav_Model_Mysql4_Entity_Attribute_Collection

Definition at line 87 of file Type.php.

00088     {
00089         if (is_null($setId)) {
00090             if (is_null($this->_attributes)) {
00091                 $this->_attributes = $this->_getAttributeCollection()
00092                     ->setEntityTypeFilter($this->getId());
00093             }
00094             $collection = $this->_attributes;
00095         }
00096         else {
00097             if (!isset($this->_attributesBySet[$setId])) {
00098                 $this->_attributesBySet[$setId] = $this->_getAttributeCollection()
00099                     ->setEntityTypeFilter($this->getId())
00100                     ->setAttributeSetFilter($setId);
00101             }
00102             $collection = $this->_attributesBySet[$setId];
00103         }
00104         return $collection;
00105     }

getAttributeModel (  ) 

Get attribute model code for entity type

Returns:
string

Definition at line 256 of file Type.php.

00257     {
00258         if (empty($this->_data['attribute_model'])) {
00259             return Mage_Eav_Model_Entity::DEFAULT_ATTRIBUTE_MODEL;
00260         }
00261         else {
00262             return $this->_data['attribute_model'];
00263         }
00264     }

getAttributeSetCollection (  ) 

Retrieve entity tpe sets collection

Returns:
Mage_Eav_Model_Mysql4_Entity_Attribute_Set_Collection

Definition at line 126 of file Type.php.

00127     {
00128         if (empty($this->_sets)) {
00129             $this->_sets = Mage::getModel('eav/entity_attribute_set')->getResourceCollection()
00130                 ->setEntityTypeFilter($this->getId());
00131         }
00132         return $this->_sets;
00133     }

getDefaultAttributeSetId (  ) 

Get default attribute set identifier for etity type

Returns:
string

Definition at line 226 of file Type.php.

00227     {
00228         return isset($this->_data['default_attribute_set_id']) ? $this->_data['default_attribute_set_id'] : null;
00229     }

getEntity (  ) 

Definition at line 266 of file Type.php.

00267     {
00268         return Mage::getResourceSingleton($this->_data['entity_model']);
00269     }

getEntityIdField (  ) 

Enter description here...

Returns:
string

Definition at line 193 of file Type.php.

00194     {
00195         return isset($this->_data['entity_id_field']) ? $this->_data['entity_id_field'] : null;
00196     }

getEntityTable (  ) 

Enter description here...

Returns:
string

Definition at line 203 of file Type.php.

00204     {
00205         return isset($this->_data['entity_table']) ? $this->_data['entity_table'] : null;
00206     }

getEntityTypeCode (  ) 

Definition at line 241 of file Type.php.

00242     {
00243         return isset($this->_data['entity_type_code']) ? $this->_data['entity_type_code'] : null;
00244     }

getEntityTypeId (  ) 

Enter description here...

Returns:
string

Definition at line 236 of file Type.php.

00237     {
00238         return isset($this->_data['entity_type_id']) ? $this->_data['entity_type_id'] : null;
00239     }

getValueTablePrefix (  ) 

Enter description here...

Returns:
string

Definition at line 213 of file Type.php.

00214     {
00215         if (empty($this->_data['value_table_prefix'])) {
00216             $this->_data['value_table_prefix'] = $this->_getResource()->getTable($this->getEntityTable());
00217         }
00218         return $this->_data['value_table_prefix'];
00219     }

loadByCode ( code  ) 

Enter description here...

Parameters:
string $code
Returns:
Mage_Eav_Model_Entity_Type

Definition at line 74 of file Type.php.

00075     {
00076         $this->_getResource()->loadByCode($this, $code);
00077         $this->_afterLoad();
00078         return $this;
00079     }


Member Data Documentation

$_attributes [protected]

Definition at line 43 of file Type.php.

$_attributesBySet = array() [protected]

Definition at line 50 of file Type.php.

$_sets [protected]

Definition at line 57 of file Type.php.


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:24:12 2009 for Magento by  doxygen 1.5.8