Mage_Catalog_Model_Abstract Class Reference

Inheritance diagram for Mage_Catalog_Model_Abstract:

Mage_Core_Model_Abstract Varien_Object Mage_Catalog_Model_Category Mage_Catalog_Model_Product

List of all members.

Public Member Functions

 lockAttribute ($attributeCode)
 unlockAttribute ($attributeCode)
 unlockAttributes ()
 getLockedAttributes ()
 hasLockedAttributes ()
 isLockedAttribute ($attributeCode)
 setData ($key, $value=null)
 unsetData ($key=null)
 getResourceCollection ()
 loadByAttribute ($attribute, $value, $additionalAttributes='*')
 getStore ()
 getWebsiteStoreIds ()
 setAttributeDefaultValue ($attributeCode, $value)
 getAttributeDefaultValue ($attributeCode)
 isDeleteable ()
 setIsDeleteable ($value)
 isReadonly ()
 setIsReadonly ($value)

Public Attributes

const DEFAULT_STORE_ID = 0

Protected Member Functions

 _beforeSave ()

Protected Attributes

 $_defaultValues = array()
 $_lockedAttributes = array()
 $_isDeleteable = true
 $_isReadonly = false


Detailed Description

Definition at line 34 of file Abstract.php.


Member Function Documentation

_beforeSave (  )  [protected]

Before save unlock attributes

Returns:
Mage_Catalog_Model_Abstract

Reimplemented from Mage_Core_Model_Abstract.

Reimplemented in Mage_Catalog_Model_Product.

Definition at line 272 of file Abstract.php.

00273     {
00274         $this->unlockAttributes();
00275         return parent::_beforeSave();
00276     }

getAttributeDefaultValue ( attributeCode  ) 

Retrieve default value for attribute code

Parameters:
string $attributeCode
Returns:
mixed

Definition at line 262 of file Abstract.php.

00263     {
00264         return isset($this->_defaultValues[$attributeCode]) ? $this->_defaultValues[$attributeCode] : null;
00265     }

getLockedAttributes (  ) 

Retrieve locked attributes

Returns:
array

Definition at line 117 of file Abstract.php.

00118     {
00119         return array_keys($this->_lockedAttributes);
00120     }

getResourceCollection (  ) 

Get collection instance

Returns:
object

Reimplemented from Mage_Core_Model_Abstract.

Reimplemented in Mage_Catalog_Model_Product.

Definition at line 202 of file Abstract.php.

00203     {
00204         $collection = parent::getResourceCollection()
00205             ->setStoreId($this->getStoreId());
00206         return $collection;
00207     }

getStore (  ) 

Retrieve sore object

Returns:
Mage_Core_Model_Store

Definition at line 227 of file Abstract.php.

00228     {
00229         return Mage::app()->getStore($this->getStoreId());
00230     }

getWebsiteStoreIds (  ) 

Retrieve all store ids of object current website

Returns:
unknown

Definition at line 237 of file Abstract.php.

00238     {
00239         return $this->getStore()->getWebsite()->getStoreIds(true);
00240     }

hasLockedAttributes (  ) 

Checks that model have locked attribtues

Returns:
boolean

Definition at line 127 of file Abstract.php.

00128     {
00129         return !empty($this->_lockedAttributes);
00130     }

isDeleteable (  ) 

Checks model is deleteable

Returns:
boolean

Definition at line 283 of file Abstract.php.

00284     {
00285         return $this->_isDeleteable;
00286     }

isLockedAttribute ( attributeCode  ) 

Retrieve locked attributes

Returns:
array

Definition at line 137 of file Abstract.php.

00138     {
00139         return isset($this->_lockedAttributes[$attributeCode]);
00140     }

isReadonly (  ) 

Checks model is deleteable

Returns:
boolean

Definition at line 305 of file Abstract.php.

00306     {
00307         return $this->_isReadonly;
00308     }

loadByAttribute ( attribute,
value,
additionalAttributes = '*' 
)

Definition at line 209 of file Abstract.php.

00210     {
00211         $collection = $this->getResourceCollection()
00212             ->addAttributeToSelect($additionalAttributes)
00213             ->addAttributeToFilter($attribute, $value)
00214             ->setPage(1,1);
00215 
00216         foreach ($collection as $object) {
00217             return $object;
00218         }
00219         return false;
00220     }

lockAttribute ( attributeCode  ) 

Lock attribute

Parameters:
string $attributeCode
Returns:
Mage_Catalog_Model_Abstract

Definition at line 80 of file Abstract.php.

00081     {
00082         $this->_lockedAttributes[$attributeCode] = true;
00083         return $this;
00084     }

setAttributeDefaultValue ( attributeCode,
value 
)

Adding attribute code and value to default value registry

Default value existing is flag for using store value in data

Parameters:
string $attributeCode
Returns:
Mage_Catalog_Model_Abstract

Definition at line 250 of file Abstract.php.

00251     {
00252         $this->_defaultValues[$attributeCode] = $value;
00253         return $this;
00254     }

setData ( key,
value = null 
)

Overwrite data in the object.

$key can be string or array. If $key is string, the attribute value will be overwritten by $value

If $key is an array, it will overwrite all the data in the object.

$isChanged will specify if the object needs to be saved after an update.

Parameters:
string|array $key
mixed $value
boolean $isChanged
Returns:
Varien_Object

Reimplemented from Varien_Object.

Definition at line 157 of file Abstract.php.

00158     {
00159         if ($this->hasLockedAttributes()) {
00160             if (is_array($key)) {
00161                  foreach ($this->getLockedAttributes() as $attribute) {
00162                      if (isset($key[$attribute])) {
00163                          unset($key[$attribute]);
00164                      }
00165                  }
00166             } elseif ($this->isLockedAttribute($key)) {
00167                 return $this;
00168             }
00169         } elseif ($this->isReadonly()) {
00170             return $this;
00171         }
00172 
00173         return parent::setData($key, $value);
00174     }

setIsDeleteable ( value  ) 

Set is deleteable flag

Parameters:
boolean $value
Returns:
Mage_Catalog_Model_Abstract

Definition at line 294 of file Abstract.php.

00295     {
00296         $this->_isDeleteable = (boolean) $value;
00297         return $this;
00298     }

setIsReadonly ( value  ) 

Set is deleteable flag

Parameters:
boolean $value
Returns:
Mage_Catalog_Model_Abstract

Definition at line 316 of file Abstract.php.

00317     {
00318         $this->_isReadonly = (boolean) $value;
00319         return $this;
00320     }

unlockAttribute ( attributeCode  ) 

Unlock attribute

Parameters:
string $attributeCode
Returns:
Mage_Catalog_Model_Abstract

Definition at line 92 of file Abstract.php.

00093     {
00094         if ($this->isLockedAttribute($attributeCode)) {
00095             unset($this->_lockedAttributes[$attributeCode]);
00096         }
00097 
00098         return $this;
00099     }

unlockAttributes (  ) 

Unlock all attributes

Returns:
Mage_Catalog_Model_Abstract

Definition at line 106 of file Abstract.php.

00107     {
00108         $this->_lockedAttributes = array();
00109         return $this;
00110     }

unsetData ( key = null  ) 

Unset data from the object.

$key can be a string only. Array will be ignored.

$isChanged will specify if the object needs to be saved after an update.

Parameters:
string $key
boolean $isChanged
Returns:
Varien_Object

Reimplemented from Varien_Object.

Definition at line 187 of file Abstract.php.

00188     {
00189         if ((!is_null($key) && $this->isLockedAttribute($key)) ||
00190             $this->isReadonly()) {
00191             return $this;
00192         }
00193 
00194         return parent::unsetData($key);
00195     }


Member Data Documentation

$_defaultValues = array() [protected]

Definition at line 50 of file Abstract.php.

$_isDeleteable = true [protected]

Definition at line 64 of file Abstract.php.

$_isReadonly = false [protected]

Definition at line 71 of file Abstract.php.

$_lockedAttributes = array() [protected]

Definition at line 57 of file Abstract.php.

const DEFAULT_STORE_ID = 0

Identifuer of default store used for loading default data for entity

Definition at line 40 of file Abstract.php.


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

Generated on Sat Jul 4 17:23:38 2009 for Magento by  doxygen 1.5.8