Documentation

Mage_Eav_Model_Attribute extends Mage_Eav_Model_Entity_Attribute
in package

AbstractYes

Table of Contents

Constants

ATTRIBUTE_CODE_MAX_LENGTH  : mixed = 64
ATTRIBUTE_CODE_PATTERN  : mixed = '/^(?!event$)[a-z][a-z_0-9]{1,254}$/'
The code of a new attribute: a letter a-z, then letters a-z, digits and underscores. "event" is not a valid code.
CACHE_TAG  : mixed = 'EAV_ATTRIBUTE'
LABEL_MAX_LENGTH  : mixed = 255
TYPE_STATIC  : mixed = 'static'

Properties

$_attributeIdCache  : array<string|int, mixed>
Attribute id cache
$_attributeValidationPassed  : bool
Attribute validation flag
$_backend  : Mage_Eav_Model_Entity_Attribute_Backend_Abstract|null
Backend instance
$_cacheTag  : mixed
$_data  : array<string|int, mixed>|null
Object attributes
$_dataSaveAllowed  : bool
Flag which can stop data saving after before save Can be used for next sequence: we check data in _beforeSave, if data are not valid - we can set this flag to false value and save process will be stopped
$_dataTable  : string
Attribute data table name
$_dirty  : array<string|int, mixed>
$_entity  : Mage_Eav_Model_Entity_Abstract
Entity instance
$_eventObject  : string
Prefix of model events object
$_eventPrefix  : string
Prefix of model events names
$_frontend  : Mage_Eav_Model_Entity_Attribute_Frontend_Abstract|null
Frontend instance
$_hasDataChanges  : bool
Data changes flag (true after setData|unsetData call)
$_idFieldName  : string
Name of object id field
$_isDeleted  : bool
Object delete flag
$_isObjectNew  : bool|null
Flag which allow detect object state: is it new object (without id) or existing one (with id)
$_name  : string
Attribute name
$_oldFieldsMap  : array<string|int, mixed>
Map short fields names to its full names
$_origData  : array<string|int, mixed>|null
Original data that was loaded
$_resource  : Mage_Core_Model_Resource_Db_Abstract
Resource model instance
$_resourceCollectionName  : string
Name of the resource collection model
$_resourceName  : string
Name of the resource model
$_source  : Mage_Eav_Model_Entity_Attribute_Source_Abstract|null
Source instance
$_syncFieldsMap  : mixed
Map of fields to sync to other fields upon changing their data
$_underscoreCache  : array<string|int, mixed>
Setter/Getter underscore transformation cache
$_website  : Mage_Core_Model_Website|null
Active Website instance

Methods

__call()  : mixed
Set/Get attribute wrapper
__construct()  : mixed
Constructor
__get()  : mixed
Attribute getter (deprecated)
__set()  : mixed
Attribute setter (deprecated)
__toArray()  : array<string|int, mixed>
Convert object attributes to array
_getResource()  : Mage_Eav_Model_Resource_Entity_Attribute
Get resource instance
addData()  : $this
Add data to the object.
afterCommitCallback()  : $this
Callback function which called after transaction commit in resource model
afterLoad()  : $this
Object after load processing. Implemented as public interface for supporting objects after load in collections
cleanModelCache()  : $this
Remove model object related cache
clearInstance()  : $this
Clearing object for correct deleting by garbage collector
dataHasChangedFor()  : bool
Compare object data with original data
debug()  : string|array<string|int, mixed>
Present object data as string in debug mode
delete()  : $this
Delete object from database
deleteEntity()  : Mage_Eav_Model_Resource_Entity_Attribute
Delete entity
flagDirty()  : $this
getAdminPageSettings()  : Mage_Eav_Model_Entity_Attribute_AdminPageSettings|null
Return the settings of the admin pages that manage the attributes of this entity type, or null when System > Attributes does not manage the type.
getAlias()  : string
Get attribute alias as "entity_type/attribute_code"
getAllowedOptionTags()  : array<int, string>
Return the HTML tags that an option label keeps when the attribute allows HTML on the storefront.
getApplyTo()  : array<string|int, mixed>
getAttributeCode()  : mixed
getAttributeCodesByFrontendType()  : array<string|int, mixed>
Retrieve attribute codes by frontend type
getAttributeGroupId()  : int|null
getAttributeId()  : int|null
Get attribute identifier
getAttributeModel()  : mixed
getAttributeSetId()  : mixed
getAttributeSetInfo()  : array<string|int, mixed>|null
getAttributeSummary()  : array{comment: string, rows: list, note: ?string}>}|null
Return the summary that the edit page of this attribute shows above the properties, or null for no summary.
getBackend()  : Mage_Eav_Model_Entity_Attribute_Backend_Abstract
Retrieve backend instance
getBackendModel()  : mixed
getBackendTable()  : string
Get attribute backend table name
getBackendType()  : mixed
getBackendTypeByInput()  : string
Detect backend storage type using frontend input type
getBillingAddress()  : Mage_Customer_Model_Address_Abstract|null
getCacheIdTags()  : array<string|int, mixed>|false
Get cache tags associated with object id
getCacheTags()  : array<string|int, mixed>|false
Get list of cache tags applied to model object.
getCollection()  : Mage_Eav_Model_Resource_Entity_Attribute_Collection
getConfig()  : $this
Retrieve attribute configuration (deprecated)
getCreatedAt()  : string|null
getData()  : mixed
Object data getter
getDataByKey()  : mixed
Get object data by particular key
getDataByPath()  : mixed
Get object data by path
getDataSetDefault()  : mixed
Fast get data or set default if value is not available
getDataUsingMethod()  : mixed
Get object data by key with calling getter method
getDefaultSourceModel()  : string
Get default source model
getDefaultValue()  : mixed
Return default value for attribute
getDefaultValueByInput()  : string
Detect default value using frontend input type
getEntity()  : Mage_Eav_Model_Entity_Abstract
Retrieve entity instance
getEntityAttributeId()  : int|null
getEntityId()  : int
getEntityIdField()  : string
Retrieve entity type
getEntityType()  : Mage_Eav_Model_Entity_Type
Retrieve entity type
getEntityTypeId()  : mixed
getFilterOptions()  : array<string|int, mixed>|null
getFrontend()  : Mage_Eav_Model_Entity_Attribute_Frontend_Abstract
Retrieve frontend instance
getFrontendClass()  : string|null
getFrontendInput()  : string|null
getFrontendLabel()  : array<string|int, mixed>|string|null
getFrontendModel()  : string|null
getId()  : int|string|null
Retrieve model object identifier
getIdByCode()  : int
Return attribute id
getIdFieldName()  : string
Retrieve identifier field name for model
getInputTypes()  : array<string, array{label: string, backend_model?: string, source_model?: string, frontend_model?: string}>
Return the input types that the admin offers for the entity type of this attribute.
getIsConfigurable()  : bool|null
getIsFilterable()  : int|null
getIsFilterableInSearch()  : bool|null
getIsRequired()  : bool|null
Return is attribute value required
getIsSearchable()  : bool|null
getIsUnique()  : bool|null
getIsUserDefined()  : bool|null
getIsVisible()  : bool|null
Return is visible attribute flag
getIsVisibleInAdvancedSearch()  : bool|null
getIsVisibleOnFront()  : mixed
getLockedFields()  : array<int, string>
Return the fields that a save cannot change on this saved attribute: the locked fields that the configuration gives for its code, and the unique flag of a system attribute.
getMultilineCount()  : mixed
Return count of lines for multiply line attribute
getName()  : string
Get attribute name
getOrigData()  : mixed
Get object loaded data (original data)
getResource()  : Mage_Eav_Model_Resource_Entity_Attribute
Retrieve model resource
getResourceCollection()  : Mage_Eav_Model_Resource_Entity_Attribute_Collection
Get collection instance
getResourceName()  : string
Retrieve model resource name
getSetDeleteQuestion()  : string
Return the question that the edit page of $set asks before it deletes the set.
getSetNote()  : string|null
Return a text that the edit page of $set shows above the groups, or null for no text.
getSetRemoveQuestion()  : string|null
Return the question that the edit page of $set asks before a save takes $attributes out of the set, or null for no question.
getShippingAddress()  : Mage_Customer_Model_Address_Abstract|null
getSortOrder()  : int|null
getSource()  : Mage_Eav_Model_Entity_Attribute_Source_Abstract
Retrieve source instance
getSourceModel()  : string|null
getStoreId()  : int|null
getStoreLabel()  : string|null
Return store label of attribute
getStoreLabels()  : array<string|int, mixed>
Return array of labels of stores
getUsedForSortBy()  : bool|null
getUsedInForms()  : array<string|int, mixed>
Return forms in which the attribute
getValidateRules()  : array<string|int, mixed>
getValidationErrors()  : Mage_Core_Exception_Input
Return one error for each value that the admin form and the API refuse. A subclass adds the rules of its entity type. A saved attribute keeps its code, its input type and its locked fields. The model does not call this method when it saves: Mage_Eav_Service_Attribute does.
getWebsite()  : Mage_Core_Model_Website
Return active website instance
hasAttributeSetInfo()  : bool
hasData()  : bool
If $key is empty, checks whether there's any data in the object Otherwise checks if the specified attribute is set.
hasDataChanges()  : bool
Get data change status
hasErrors()  : bool
hasIsVisible()  : bool
isAttributeValidationPassed()  : bool
Check if attribute is valid
isDeleted()  : bool
Set _isDeleted flag value (if $isDeleted param is defined) and return current flag value
isDirty()  : bool
isEmpty()  : bool
checks whether the object is empty
isInGroup()  : bool
Check if attribute in specified group
isInSet()  : bool
Check if attribute in specified set
isModuleEnabled()  : bool
isObjectNew()  : bool
Check object state (true - if it is object without id on object just created) This method can help detect if object just created in _afterSave method problem is what in after save object has id and we can't detect what object was created in this transaction
isStatic()  : bool
Check if attribute is static
isValueEmpty()  : bool
jsonSerialize()  : array<string|int, mixed>
Implementation of JsonSerializable::jsonSerialize()
load()  : $this
Load object data
loadByCode()  : $this
Load attribute data by code
loadEntityAttributeIdBySet()  : $this
Load entity_attribute_id into $this by $this->attribute_set_id
offsetExists()  : bool
Implementation of ArrayAccess::offsetExists()
offsetGet()  : mixed
Implementation of ArrayAccess::offsetGet()
offsetSet()  : void
Implementation of ArrayAccess::offsetSet()
offsetUnset()  : void
Implementation of ArrayAccess::offsetUnset()
prepareAdminData()  : array<string|int, mixed>
Turn the posted values of the admin attribute form into the data of this attribute.
save()  : $this
Save object data
saveAdminData()  : void
Save the posted values of the admin attribute form that the attribute does not save itself.
serialize()  : string
serialize object attributes
setAttribute()  : $this
setAttributeCode()  : $this
setAttributeGroupId()  : static
setAttributeId()  : $this
Specify attribute identifier
setAttributeModel()  : $this
setAttributeSetId()  : $this
setAttributeSetInfo()  : static
setAttributeValidationAsPassed()  : mixed
Mark current attribute as passed validation
setBackendModel()  : $this
setBackendTable()  : $this
setBackendType()  : $this
setCreatedAt()  : static
setData()  : $this
Overwrite data in the object.
setDataChanges()  : $this
Clears data changes status
setDataUsingMethod()  : $this
Set object data with calling setter method
setDefaultValue()  : static
setEntity()  : $this
Set attribute entity instance
setEntityAttributeId()  : static
setEntityType()  : $this
setEntityTypeId()  : $this
setFrontendLabel()  : static
setFrontendModel()  : static
setId()  : $this
Declare model object identifier value
setIdFieldName()  : $this
set name of object id field
setIsFilterable()  : static
setIsGlobal()  : static
setName()  : $this
Set attribute name
setOrigData()  : $this
Initialize object original data
setSortOrder()  : static
setSourceModel()  : static
setStoreId()  : static
setUpdatedAt()  : static
setValidateRules()  : static
setWebsite()  : Mage_Eav_Model_Attribute
Set active website instance
toArray()  : array<string|int, mixed>
Public wrapper for __toArray
toJson()  : string
Public wrapper for __toJson
toString()  : string
Public wrapper for __toString
toXml()  : string
Public wrapper for __toXml
unsetData()  : $this
Unset data from the object.
unsetOldData()  : $this
Unset old fields data from the object.
unsIsVisible()  : $this
usesSource()  : bool
__toJson()  : string
Convert object attributes to JSON
__toXml()  : string
Convert object attributes to XML
_addFullNames()  : mixed
_afterDelete()  : $this
Processing object after delete data
_afterDeleteCommit()  : $this
Processing manipulation after main transaction commit
_afterLoad()  : $this
Processing object after load data
_afterSave()  : $this
Save additional data
_beforeDelete()  : $this
Processing object before delete data
_beforeLoad()  : $this
Processing object before load data
_beforeSave()  : $this
The column limits the length of the code. Mage_Eav_Service_Attribute checks the rules of the admin form and of the API with getValidationErrors(), so a setup script can save a code that the form refuses.
_camelize()  : string
_clearData()  : $this
Clearing object's data
_clearReferences()  : $this
Clearing cyclic references
_construct()  : void
Internal constructor not depended on params. Can be used for object initialization
_getData()  : mixed
Get value from _data array without parse key
_getDefaultBackendModel()  : string
Retrieve default attribute backend model by attribute code
_getDefaultFrontendModel()  : string
Retrieve default attribute frontend model
_getDefaultSourceModel()  : string
Retrieve default attribute source model
_getEventData()  : array<string|int, mixed>
Get array of objects transferred to default events processing
_getInputTypes()  : array<string, array{label: string, backend_model?: string, source_model?: string, frontend_model?: string}>
_getScopeValue()  : mixed
Return scope value by key
_hasModelChanged()  : bool
Check whether model has changed data.
_init()  : mixed
Standard model initialization
_initOldFieldsMap()  : mixed
Inits mapping array of object's previously used fields to new fields.
_prepareArray()  : array<string|int, mixed>
Set required array elements
_prepareSyncFieldsMap()  : $this
Called after old fields are inited. Forms synchronization map to sync old fields and new fields between each other.
_protectFromNonAdmin()  : mixed
Safeguard func that will check, if we are in admin area
_setResourceModel()  : mixed
Set resource names
_underscore()  : string
Converts field names for setters and getters
assignFirstGroupOfDefaultSet()  : void
Put this attribute in the first group of the default set of its entity type, so that the records show it at once. The save writes the set and the group.
getQuestionLabel()  : string
Return the label of $attribute for a question, or its code when it has no label.
getQuestionLabels()  : string
Return the labels of $attributes for a question, separated by commas.
hasChangedStoredValue()  : bool
Tell whether $field holds a value that differs from the value that the attribute had when it was loaded.
isValueChanged()  : bool
Tell whether a save writes a new value of $field: the attribute is new and has a value, or the attribute was loaded and the value changed since. An attribute from Mage_Eav_Model_Config has no loaded values, so a save of it does not check the values that it already had.

Constants

ATTRIBUTE_CODE_MAX_LENGTH

public mixed ATTRIBUTE_CODE_MAX_LENGTH = 64

ATTRIBUTE_CODE_PATTERN

The code of a new attribute: a letter a-z, then letters a-z, digits and underscores. "event" is not a valid code.

public mixed ATTRIBUTE_CODE_PATTERN = '/^(?!event$)[a-z][a-z_0-9]{1,254}$/'

CACHE_TAG

public mixed CACHE_TAG = 'EAV_ATTRIBUTE'

LABEL_MAX_LENGTH

public mixed LABEL_MAX_LENGTH = 255

TYPE_STATIC

public mixed TYPE_STATIC = 'static'

Properties

$_attributeIdCache

Attribute id cache

protected array<string|int, mixed> $_attributeIdCache = []

$_attributeValidationPassed

Attribute validation flag

protected bool $_attributeValidationPassed = \false

$_cacheTag

protected mixed $_cacheTag = 'EAV_ATTRIBUTE'
Attributes
#[Override]

$_data

Object attributes

protected array<string|int, mixed>|null $_data = []

$_dataSaveAllowed

Flag which can stop data saving after before save Can be used for next sequence: we check data in _beforeSave, if data are not valid - we can set this flag to false value and save process will be stopped

protected bool $_dataSaveAllowed = \true

$_dataTable

Attribute data table name

protected string $_dataTable = \null

$_dirty

protected array<string|int, mixed> $_dirty

$_eventObject

Prefix of model events object

protected string $_eventObject = 'attribute'
Attributes
#[Override]

$_eventPrefix

Prefix of model events names

protected string $_eventPrefix = 'eav_entity_attribute'
Attributes
#[Override]

$_hasDataChanges

Data changes flag (true after setData|unsetData call)

protected bool $_hasDataChanges = false

$_idFieldName

Name of object id field

protected string $_idFieldName = null

$_isDeleted

Object delete flag

protected bool $_isDeleted = false

$_isObjectNew

Flag which allow detect object state: is it new object (without id) or existing one (with id)

protected bool|null $_isObjectNew = \null

$_name

Attribute name

protected string $_name

$_oldFieldsMap

Map short fields names to its full names

protected array<string|int, mixed> $_oldFieldsMap = []

$_origData

Original data that was loaded

protected array<string|int, mixed>|null $_origData

$_resourceCollectionName

Name of the resource collection model

protected string $_resourceCollectionName

$_resourceName

Name of the resource model

protected string $_resourceName

$_syncFieldsMap

Map of fields to sync to other fields upon changing their data

protected mixed $_syncFieldsMap = []

$_underscoreCache

Setter/Getter underscore transformation cache

protected static array<string|int, mixed> $_underscoreCache = []

Methods

__call()

Set/Get attribute wrapper

public __call(string $method, array<string|int, mixed> $args) : mixed
Parameters
$method : string
$args : array<string|int, mixed>

__construct()

Constructor

public __construct() : mixed

By default, is looking for first argument as array and assigns it as object attributes This behaviour may change in child classes

__get()

Attribute getter (deprecated)

public __get(string $var) : mixed
Parameters
$var : string

__set()

Attribute setter (deprecated)

public __set(string $var, mixed $value) : mixed
Parameters
$var : string
$value : mixed

__toArray()

Convert object attributes to array

public __toArray([array<string|int, mixed> $arrAttributes = [] ]) : array<string|int, mixed>
Parameters
$arrAttributes : array<string|int, mixed> = []

array of required attributes

Return values
array<string|int, mixed>

addData()

Add data to the object.

public addData(array<string|int, mixed> $arr) : $this

Retains previous data in the object.

Parameters
$arr : array<string|int, mixed>
Return values
$this

afterCommitCallback()

Callback function which called after transaction commit in resource model

public afterCommitCallback() : $this
Return values
$this

afterLoad()

Object after load processing. Implemented as public interface for supporting objects after load in collections

public afterLoad() : $this
Return values
$this

cleanModelCache()

Remove model object related cache

public cleanModelCache() : $this
Return values
$this

clearInstance()

Clearing object for correct deleting by garbage collector

public final clearInstance() : $this
Return values
$this

dataHasChangedFor()

Compare object data with original data

public dataHasChangedFor(string $field) : bool
Parameters
$field : string
Return values
bool

debug()

Present object data as string in debug mode

public debug([mixed $data = null ][, array<string|int, mixed> &$objects = [] ]) : string|array<string|int, mixed>
Parameters
$data : mixed = null
$objects : array<string|int, mixed> = []
Return values
string|array<string|int, mixed>

delete()

Delete object from database

public delete() : $this
Tags
throws
Throwable
Return values
$this

flagDirty()

public flagDirty(string $field[, bool $flag = true ]) : $this
Parameters
$field : string
$flag : bool = true
Return values
$this

getAllowedOptionTags()

Return the HTML tags that an option label keeps when the attribute allows HTML on the storefront.

public getAllowedOptionTags() : array<int, string>
Return values
array<int, string>

getApplyTo()

public getApplyTo() : array<string|int, mixed>
Return values
array<string|int, mixed>

getAttributeCode()

public getAttributeCode() : mixed

getAttributeCodesByFrontendType()

Retrieve attribute codes by frontend type

public getAttributeCodesByFrontendType(string $type) : array<string|int, mixed>
Parameters
$type : string
Return values
array<string|int, mixed>

getAttributeGroupId()

public getAttributeGroupId() : int|null
Return values
int|null

getAttributeId()

Get attribute identifier

public getAttributeId() : int|null
Return values
int|null

getAttributeModel()

public getAttributeModel() : mixed

getAttributeSetId()

public getAttributeSetId() : mixed

getAttributeSetInfo()

public getAttributeSetInfo() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|null

getAttributeSummary()

Return the summary that the edit page of this attribute shows above the properties, or null for no summary.

public getAttributeSummary() : array{comment: string, rows: list, note: ?string}>}|null

Each row names one setting and lists its values. A value that does not show the attribute has shown false. A row note explains the row.

Return values
array{comment: string, rows: list, note: ?string}>}|null

getBackendModel()

public getBackendModel() : mixed

getBackendTable()

Get attribute backend table name

public getBackendTable() : string
Return values
string

getBackendType()

public getBackendType() : mixed

getBackendTypeByInput()

Detect backend storage type using frontend input type

public getBackendTypeByInput(string $type) : string
Parameters
$type : string

frontend_input field value

Return values
string —

backend_type field value

getCacheIdTags()

Get cache tags associated with object id

public getCacheIdTags() : array<string|int, mixed>|false
Return values
array<string|int, mixed>|false

getCacheTags()

Get list of cache tags applied to model object.

public getCacheTags() : array<string|int, mixed>|false

Return false if cache tags are not supported by model

Return values
array<string|int, mixed>|false

getConfig()

Retrieve attribute configuration (deprecated)

public getConfig() : $this
Return values
$this

getCreatedAt()

public getCreatedAt() : string|null
Return values
string|null

getData()

Object data getter

public getData([string $key = '' ][, string|int $index = null ]) : mixed

If $key is not defined will return all the data as an array. Otherwise, it will return value of the element specified by $key. It is possible to use keys like a/b/c for access nested array data

If $index is specified it will assume that attribute data is an array and retrieve corresponding member. If data is the string - it will be explode by new line character and converted to array.

Parameters
$key : string = ''
$index : string|int = null

getDataByKey()

Get object data by particular key

public getDataByKey(string $key) : mixed
Parameters
$key : string

getDataByPath()

Get object data by path

public getDataByPath(string $path) : mixed

Method consider the path as chain of keys: a/b/c => ['a']['b']['c']

Parameters
$path : string

getDataSetDefault()

Fast get data or set default if value is not available

public getDataSetDefault(string $key, mixed $default) : mixed
Parameters
$key : string
$default : mixed

getDataUsingMethod()

Get object data by key with calling getter method

public getDataUsingMethod(string $key[, mixed $args = null ]) : mixed
Parameters
$key : string
$args : mixed = null

getDefaultSourceModel()

Get default source model

public getDefaultSourceModel() : string
Attributes
#[Override]
Return values
string

getDefaultValue()

Return default value for attribute

public getDefaultValue() : mixed
Attributes
#[Override]

getDefaultValueByInput()

Detect default value using frontend input type

public getDefaultValueByInput(string $type) : string
Parameters
$type : string

frontend_input field name

Return values
string —

default_value field value

getEntityAttributeId()

public getEntityAttributeId() : int|null
Return values
int|null

getEntityId()

public getEntityId() : int
Return values
int

getEntityIdField()

Retrieve entity type

public getEntityIdField() : string
Return values
string

getEntityTypeId()

public getEntityTypeId() : mixed

getFilterOptions()

public getFilterOptions() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|null

getFrontendClass()

public getFrontendClass() : string|null
Return values
string|null

getFrontendInput()

public getFrontendInput() : string|null
Return values
string|null

getFrontendLabel()

public getFrontendLabel() : array<string|int, mixed>|string|null
Return values
array<string|int, mixed>|string|null

getFrontendModel()

public getFrontendModel() : string|null
Return values
string|null

getId()

Retrieve model object identifier

public getId() : int|string|null
Attributes
#[Override]
Return values
int|string|null

getIdByCode()

Return attribute id

public getIdByCode(string $entityType, string $code) : int
Parameters
$entityType : string
$code : string
Return values
int

getIdFieldName()

Retrieve identifier field name for model

public getIdFieldName() : string
Attributes
#[Override]
Return values
string

getInputTypes()

Return the input types that the admin offers for the entity type of this attribute.

public getInputTypes() : array<string, array{label: string, backend_model?: string, source_model?: string, frontend_model?: string}>

The key is the input code. Each type has a label, and can name a backend_model, a source_model and a frontend_model. The event eav_attribute_input_types_prepare lets a module add or remove a type.

Return values
array<string, array{label: string, backend_model?: string, source_model?: string, frontend_model?: string}>

getIsConfigurable()

public getIsConfigurable() : bool|null
Return values
bool|null

getIsFilterable()

public getIsFilterable() : int|null
Return values
int|null

getIsFilterableInSearch()

public getIsFilterableInSearch() : bool|null
Return values
bool|null

getIsRequired()

Return is attribute value required

public getIsRequired() : bool|null
Attributes
#[Override]
Return values
bool|null

getIsSearchable()

public getIsSearchable() : bool|null
Return values
bool|null

getIsUnique()

public getIsUnique() : bool|null
Return values
bool|null

getIsUserDefined()

public getIsUserDefined() : bool|null
Return values
bool|null

getIsVisible()

Return is visible attribute flag

public getIsVisible() : bool|null
Attributes
#[Override]
Return values
bool|null

getIsVisibleInAdvancedSearch()

public getIsVisibleInAdvancedSearch() : bool|null
Return values
bool|null

getIsVisibleOnFront()

public getIsVisibleOnFront() : mixed

getLockedFields()

Return the fields that a save cannot change on this saved attribute: the locked fields that the configuration gives for its code, and the unique flag of a system attribute.

public getLockedFields() : array<int, string>
Return values
array<int, string>

getMultilineCount()

Return count of lines for multiply line attribute

public getMultilineCount() : mixed

getName()

Get attribute name

public getName() : string
Return values
string

getOrigData()

Get object loaded data (original data)

public getOrigData([string $key = null ]) : mixed
Parameters
$key : string = null

getResourceName()

Retrieve model resource name

public getResourceName() : string
Return values
string

getSetDeleteQuestion()

Return the question that the edit page of $set asks before it deletes the set.

public getSetDeleteQuestion(Mage_Eav_Model_Entity_Attribute_Set $set) : string

The records of the set move to the default set. The nightly eav_clean_orphaned_records job then deletes their values of the attributes that are not in the default set, so the question names those attributes.

Parameters
$set : Mage_Eav_Model_Entity_Attribute_Set
Return values
string

getSetRemoveQuestion()

Return the question that the edit page of $set asks before a save takes $attributes out of the set, or null for no question.

public getSetRemoveQuestion(Mage_Eav_Model_Entity_Attribute_Set $set, array<int, Mage_Eav_Model_Entity_Attribute_Abstract> $attributes) : string|null

The nightly eav_clean_orphaned_records job deletes the values of an attribute that is not in the set of the record, so the question names each attribute and its number of records with a value.

Parameters
$set : Mage_Eav_Model_Entity_Attribute_Set
$attributes : array<int, Mage_Eav_Model_Entity_Attribute_Abstract>
Return values
string|null

getSortOrder()

public getSortOrder() : int|null
Return values
int|null

getSourceModel()

public getSourceModel() : string|null
Return values
string|null

getStoreId()

public getStoreId() : int|null
Return values
int|null

getStoreLabels()

Return array of labels of stores

public getStoreLabels() : array<string|int, mixed>
Return values
array<string|int, mixed>

getUsedForSortBy()

public getUsedForSortBy() : bool|null
Return values
bool|null

getUsedInForms()

Return forms in which the attribute

public getUsedInForms() : array<string|int, mixed>
Return values
array<string|int, mixed>

getValidateRules()

public getValidateRules() : array<string|int, mixed>
Return values
array<string|int, mixed>

getValidationErrors()

Return one error for each value that the admin form and the API refuse. A subclass adds the rules of its entity type. A saved attribute keeps its code, its input type and its locked fields. The model does not call this method when it saves: Mage_Eav_Service_Attribute does.

public getValidationErrors() : Mage_Core_Exception_Input
Return values
Mage_Core_Exception_Input

hasAttributeSetInfo()

public hasAttributeSetInfo() : bool
Return values
bool

hasData()

If $key is empty, checks whether there's any data in the object Otherwise checks if the specified attribute is set.

public hasData([string $key = '' ]) : bool
Parameters
$key : string = ''
Return values
bool

hasDataChanges()

Get data change status

public hasDataChanges() : bool
Return values
bool

hasErrors()

public hasErrors() : bool
Return values
bool

hasIsVisible()

public hasIsVisible() : bool
Return values
bool

isAttributeValidationPassed()

Check if attribute is valid

public isAttributeValidationPassed() : bool
Return values
bool

isDeleted()

Set _isDeleted flag value (if $isDeleted param is defined) and return current flag value

public isDeleted([bool $isDeleted = null ]) : bool
Parameters
$isDeleted : bool = null
Return values
bool

isDirty()

public isDirty([string $field = null ]) : bool
Parameters
$field : string = null
Return values
bool

isEmpty()

checks whether the object is empty

public isEmpty() : bool
Return values
bool

isInGroup()

Check if attribute in specified group

public isInGroup(int $setId, int $groupId) : bool
Parameters
$setId : int
$groupId : int
Return values
bool

isInSet()

Check if attribute in specified set

public isInSet(int|array<string|int, mixed> $setId) : bool
Parameters
$setId : int|array<string|int, mixed>
Return values
bool

isModuleEnabled()

public isModuleEnabled(string $moduleName[, string $helperAlias = 'core' ]) : bool
Parameters
$moduleName : string
$helperAlias : string = 'core'
Return values
bool

isObjectNew()

Check object state (true - if it is object without id on object just created) This method can help detect if object just created in _afterSave method problem is what in after save object has id and we can't detect what object was created in this transaction

public isObjectNew([bool $flag = null ]) : bool
Parameters
$flag : bool = null
Return values
bool

isStatic()

Check if attribute is static

public isStatic() : bool
Return values
bool

jsonSerialize()

Implementation of JsonSerializable::jsonSerialize()

public jsonSerialize() : array<string|int, mixed>

Prepares the object data for JSON serialization. Returns all object data as an array, with special handling for nested DataObject instances:

  • If a nested DataObject has a custom jsonSerialize() implementation, it's preserved as-is
  • If a nested DataObject has a custom toJson() method, it's converted to JSON string
  • If a nested DataObject uses only the base implementations, it's excluded from output

This prevents infinite recursion and circular references when serializing object hierarchies.

Attributes
#[Override]
Return values
array<string|int, mixed>

load()

Load object data

public load(string|null|int $id[, string|null $field = null ]) : $this
Parameters
$id : string|null|int
$field : string|null = null
Return values
$this

loadByCode()

Load attribute data by code

public loadByCode(mixed $entityType, string $code) : $this
Parameters
$entityType : mixed
$code : string
Return values
$this

loadEntityAttributeIdBySet()

Load entity_attribute_id into $this by $this->attribute_set_id

public loadEntityAttributeIdBySet() : $this
Return values
$this

prepareAdminData()

Turn the posted values of the admin attribute form into the data of this attribute.

public prepareAdminData(array<string|int, mixed> $data) : array<string|int, mixed>

The attribute is loaded when it exists.

Parameters
$data : array<string|int, mixed>
Return values
array<string|int, mixed>

save()

Save object data

public save() : $this
Tags
throws
Throwable
Return values
$this

saveAdminData()

Save the posted values of the admin attribute form that the attribute does not save itself.

public saveAdminData(array<string|int, mixed> $data) : void
Parameters
$data : array<string|int, mixed>

serialize()

serialize object attributes

public serialize([array<string|int, mixed> $attributes = [] ][, string $valueSeparator = '=' ][, string $fieldSeparator = ' ' ][, string $quote = '"' ]) : string
Parameters
$attributes : array<string|int, mixed> = []
$valueSeparator : string = '='
$fieldSeparator : string = ' '
$quote : string = '"'
Return values
string

setAttributeCode()

public setAttributeCode(mixed $data) : $this
Parameters
$data : mixed
Return values
$this

setAttributeGroupId()

public setAttributeGroupId(int|null $value) : static
Parameters
$value : int|null
Return values
static

setAttributeId()

Specify attribute identifier

public setAttributeId(int $data) : $this
Parameters
$data : int
Return values
$this

setAttributeModel()

public setAttributeModel(mixed $data) : $this
Parameters
$data : mixed
Return values
$this

setAttributeSetId()

public setAttributeSetId(mixed $id) : $this
Parameters
$id : mixed
Return values
$this

setAttributeSetInfo()

public setAttributeSetInfo(array<string|int, mixed>|null $value) : static
Parameters
$value : array<string|int, mixed>|null
Return values
static

setAttributeValidationAsPassed()

Mark current attribute as passed validation

public setAttributeValidationAsPassed() : mixed

setBackendModel()

public setBackendModel(mixed $data) : $this
Parameters
$data : mixed
Return values
$this

setBackendTable()

public setBackendTable(mixed $data) : $this
Parameters
$data : mixed
Return values
$this

setBackendType()

public setBackendType(mixed $data) : $this
Parameters
$data : mixed
Return values
$this

setCreatedAt()

public setCreatedAt(string|null $value) : static
Parameters
$value : string|null
Return values
static

setData()

Overwrite data in the object.

public setData(string|array<string|int, mixed> $key[, mixed $value = null ]) : $this

$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.

Parameters
$key : string|array<string|int, mixed>
$value : mixed = null
Return values
$this

setDataChanges()

Clears data changes status

public setDataChanges(bool $value) : $this
Parameters
$value : bool
Return values
$this

setDataUsingMethod()

Set object data with calling setter method

public setDataUsingMethod(string $key[, mixed $args = [] ]) : $this
Parameters
$key : string
$args : mixed = []
Return values
$this

setDefaultValue()

public setDefaultValue(int|string|null $value) : static
Parameters
$value : int|string|null
Return values
static

setEntityAttributeId()

public setEntityAttributeId(int|null $value) : static
Parameters
$value : int|null
Return values
static

setEntityType()

public setEntityType(mixed $type) : $this
Parameters
$type : mixed
Return values
$this

setEntityTypeId()

public setEntityTypeId(mixed $id) : $this
Parameters
$id : mixed
Return values
$this

setFrontendLabel()

public setFrontendLabel(string|null $value) : static
Parameters
$value : string|null
Return values
static

setFrontendModel()

public setFrontendModel(string|null $value) : static
Parameters
$value : string|null
Return values
static

setId()

Declare model object identifier value

public setId(mixed $id) : $this
Parameters
$id : mixed
Attributes
#[Override]
Return values
$this

setIdFieldName()

set name of object id field

public setIdFieldName(string $name) : $this
Parameters
$name : string
Return values
$this

setIsFilterable()

public setIsFilterable(int|null $value) : static
Parameters
$value : int|null
Return values
static

setIsGlobal()

public setIsGlobal(int|null $value) : static
Parameters
$value : int|null
Return values
static

setName()

Set attribute name

public setName(string $name) : $this
Parameters
$name : string
Return values
$this

setOrigData()

Initialize object original data

public setOrigData([string $key = null ][, mixed $data = null ]) : $this
Parameters
$key : string = null
$data : mixed = null
Return values
$this

setSortOrder()

public setSortOrder(int|null $value) : static
Parameters
$value : int|null
Return values
static

setSourceModel()

public setSourceModel(string|null $value) : static
Parameters
$value : string|null
Return values
static

setStoreId()

public setStoreId(int|null $value) : static
Parameters
$value : int|null
Return values
static

setUpdatedAt()

public setUpdatedAt(string|null $value) : static
Parameters
$value : string|null
Return values
static

setValidateRules()

public setValidateRules(array<string|int, mixed>|string|null $value) : static
Parameters
$value : array<string|int, mixed>|string|null
Return values
static

toArray()

Public wrapper for __toArray

public toArray([array<string|int, mixed> $arrAttributes = [] ]) : array<string|int, mixed>
Parameters
$arrAttributes : array<string|int, mixed> = []
Return values
array<string|int, mixed>

toJson()

Public wrapper for __toJson

public toJson([array<string|int, mixed> $arrAttributes = [] ]) : string
Parameters
$arrAttributes : array<string|int, mixed> = []
Return values
string

toString()

Public wrapper for __toString

public toString([string $format = '' ]) : string

Will use $format as an template and substitute {{key}} for attributes

Parameters
$format : string = ''
Return values
string

toXml()

Public wrapper for __toXml

public toXml([array<string|int, mixed> $arrAttributes = [] ][, string $rootName = 'item' ][, bool $addOpenTag = false ][, bool $addCdata = true ]) : string
Parameters
$arrAttributes : array<string|int, mixed> = []
$rootName : string = 'item'
$addOpenTag : bool = false
$addCdata : bool = true
Return values
string

unsetData()

Unset data from the object.

public unsetData([string $key = null ]) : $this

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

Parameters
$key : string = null
Return values
$this

unsetOldData()

Unset old fields data from the object.

public unsetOldData([string $key = null ]) : $this

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

Parameters
$key : string = null
Return values
$this

unsIsVisible()

public unsIsVisible() : $this
Return values
$this

usesSource()

public usesSource() : bool
Return values
bool

__toJson()

Convert object attributes to JSON

protected __toJson([array<string|int, mixed> $arrAttributes = [] ]) : string
Parameters
$arrAttributes : array<string|int, mixed> = []

array of required attributes

Return values
string

__toXml()

Convert object attributes to XML

protected __toXml([array<string|int, mixed> $arrAttributes = [] ][, string $rootName = 'item' ][, bool $addOpenTag = false ][, bool $addCdata = true ]) : string
Parameters
$arrAttributes : array<string|int, mixed> = []

array of required attributes

$rootName : string = 'item'

name of the root element

$addOpenTag : bool = false
$addCdata : bool = true
Return values
string

_addFullNames()

protected _addFullNames() : mixed

_afterDelete()

Processing object after delete data

protected _afterDelete() : $this
Return values
$this

_afterDeleteCommit()

Processing manipulation after main transaction commit

protected _afterDeleteCommit() : $this
Return values
$this

_afterLoad()

Processing object after load data

protected _afterLoad() : $this
Return values
$this

_afterSave()

Save additional data

protected _afterSave() : $this
Attributes
#[Override]
Return values
$this

_beforeDelete()

Processing object before delete data

protected _beforeDelete() : $this
Return values
$this

_beforeLoad()

Processing object before load data

protected _beforeLoad(int $id[, string|null $field = null ]) : $this
Parameters
$id : int
$field : string|null = null
Return values
$this

_beforeSave()

The column limits the length of the code. Mage_Eav_Service_Attribute checks the rules of the admin form and of the API with getValidationErrors(), so a setup script can save a code that the form refuses.

protected _beforeSave() : $this
Tags
throws
Mage_Eav_Exception
Attributes
#[Override]
Return values
$this

_camelize()

protected _camelize(string $name) : string
Parameters
$name : string
Return values
string

_clearData()

Clearing object's data

protected _clearData() : $this
Return values
$this

_clearReferences()

Clearing cyclic references

protected _clearReferences() : $this
Return values
$this

_construct()

Internal constructor not depended on params. Can be used for object initialization

protected _construct() : void
Attributes
#[Override]

_getData()

Get value from _data array without parse key

protected _getData(string $key) : mixed
Parameters
$key : string

_getDefaultBackendModel()

Retrieve default attribute backend model by attribute code

protected _getDefaultBackendModel() : string
Attributes
#[Override]
Return values
string

_getDefaultFrontendModel()

Retrieve default attribute frontend model

protected _getDefaultFrontendModel() : string
Attributes
#[Override]
Return values
string

_getDefaultSourceModel()

Retrieve default attribute source model

protected _getDefaultSourceModel() : string

since 26.1 use getDefaultSourceModel() instead

Attributes
#[Override]
Return values
string

_getEventData()

Get array of objects transferred to default events processing

protected _getEventData() : array<string|int, mixed>
Return values
array<string|int, mixed>

_getInputTypes()

protected _getInputTypes() : array<string, array{label: string, backend_model?: string, source_model?: string, frontend_model?: string}>
Return values
array<string, array{label: string, backend_model?: string, source_model?: string, frontend_model?: string}>

_getScopeValue()

Return scope value by key

protected _getScopeValue(string $key) : mixed
Parameters
$key : string

_hasModelChanged()

Check whether model has changed data.

protected _hasModelChanged() : bool

Can be overloaded in child classes to perform advanced check whether model needs to be saved e.g. using resourceModel->hasDataChanged() or any other technique

Return values
bool

_init()

Standard model initialization

protected _init(string $resourceModel) : mixed
Parameters
$resourceModel : string

_initOldFieldsMap()

Inits mapping array of object's previously used fields to new fields.

protected _initOldFieldsMap() : mixed

Must be overloaded by descendants to set concrete fields map.

_prepareArray()

Set required array elements

protected _prepareArray(array<string|int, mixed> &$arr[, array<string|int, mixed> $elements = [] ]) : array<string|int, mixed>
Parameters
$arr : array<string|int, mixed>
$elements : array<string|int, mixed> = []
Return values
array<string|int, mixed>

_prepareSyncFieldsMap()

Called after old fields are inited. Forms synchronization map to sync old fields and new fields between each other.

protected _prepareSyncFieldsMap() : $this
Return values
$this

_protectFromNonAdmin()

Safeguard func that will check, if we are in admin area

protected _protectFromNonAdmin() : mixed
Tags
throws
Mage_Core_Exception

_setResourceModel()

Set resource names

protected _setResourceModel(string $resourceName[, string|null $resourceCollectionName = null ]) : mixed

If collection name is omitted, resource name will be used with _collection appended

Parameters
$resourceName : string
$resourceCollectionName : string|null = null

_underscore()

Converts field names for setters and getters

protected _underscore(string $name) : string

$this->setMyField($value) === $this->setData('my_field', $value) Uses cache to eliminate unnecessary preg_replace

Parameters
$name : string
Return values
string

assignFirstGroupOfDefaultSet()

Put this attribute in the first group of the default set of its entity type, so that the records show it at once. The save writes the set and the group.

protected assignFirstGroupOfDefaultSet() : void

hasChangedStoredValue()

Tell whether $field holds a value that differs from the value that the attribute had when it was loaded.

protected hasChangedStoredValue(string $field) : bool
Parameters
$field : string
Return values
bool

isValueChanged()

Tell whether a save writes a new value of $field: the attribute is new and has a value, or the attribute was loaded and the value changed since. An attribute from Mage_Eav_Model_Config has no loaded values, so a save of it does not check the values that it already had.

protected isValueChanged(string $field) : bool
Parameters
$field : string
Return values
bool
On this page

Search results