Mage_Eav_Model_Mysql4_Entity_Attribute_Set Class Reference

Inheritance diagram for Mage_Eav_Model_Mysql4_Entity_Attribute_Set:

Mage_Core_Model_Mysql4_Abstract Mage_Core_Model_Resource_Abstract

List of all members.

Public Member Functions

 validate ($object, $name)
 getSetInfo (array $attributeIds, $setId=null)

Protected Member Functions

 _construct ()
 _afterSave (Mage_Core_Model_Abstract $object)


Detailed Description

Definition at line 35 of file Set.php.


Member Function Documentation

_afterSave ( Mage_Core_Model_Abstract object  )  [protected]

Perform actions after object save

Parameters:
Mage_Core_Model_Abstract $object
Returns:
Mage_Eav_Model_Mysql4_Entity_Attribute_Set

Reimplemented from Mage_Core_Model_Mysql4_Abstract.

Definition at line 52 of file Set.php.

00053     {
00054         if ($object->getGroups()) {
00055             foreach ($object->getGroups() as $group) {
00056                 /* @var $group Mage_Eav_Model_Entity_Attribute_Group */
00057                 $group->setAttributeSetId($object->getId());
00058                 $group->save();
00059             }
00060         }
00061         if ($object->getRemoveGroups()) {
00062             foreach ($object->getRemoveGroups() as $group) {
00063                 /* @var $group Mage_Eav_Model_Entity_Attribute_Group */
00064                 $group->delete();
00065             }
00066         }
00067         if ($object->getRemoveAttributes()) {
00068             foreach ($object->getRemoveAttributes() as $attribute) {
00069                 /* @var $attribute Mage_Eav_Model_Entity_Attribute */
00070                 $attribute->deleteEntity();
00071             }
00072         }
00073         return parent::_afterSave($object);
00074     }

_construct (  )  [protected]

Initialize connection

Reimplemented from Mage_Core_Model_Resource_Abstract.

Definition at line 41 of file Set.php.

00042     {
00043         $this->_init('eav/attribute_set', 'attribute_set_id');
00044     }

getSetInfo ( array attributeIds,
setId = null 
)

Retrieve Set info by attributes

Parameters:
array $attributeIds
int $setId
Returns:
array

Definition at line 108 of file Set.php.

00109     {
00110         $setInfo            = array();
00111         $attributeToSetInfo = array();
00112         if (count($attributeIds) > 0) {
00113             $select = $this->_getReadAdapter()->select()
00114                 ->from(
00115                     array('entity' => $this->getTable('entity_attribute')),
00116                     array('attribute_id','attribute_set_id', 'attribute_group_id', 'sort_order'))
00117                 ->joinLeft(
00118                     array('group' => $this->getTable('attribute_group')),
00119                     'entity.attribute_group_id=group.attribute_group_id',
00120                     array('group_sort_order' => 'sort_order'))
00121                 ->where('entity.attribute_id IN (?)', $attributeIds);
00122             if (is_numeric($setId)) {
00123                 $select->where('entity.attribute_set_id=?', $setId);
00124             }
00125             $result = $this->_getReadAdapter()->fetchAll($select);
00126 
00127             foreach ($result as $row) {
00128                 $data = array(
00129                     'group_id'      => $row['attribute_group_id'],
00130                     'group_sort'    => $row['group_sort_order'],
00131                     'sort'          => $row['sort_order']
00132                 );
00133                 $attributeToSetInfo[$row['attribute_id']][$row['attribute_set_id']] = $data;
00134             }
00135         }
00136 
00137         foreach ($attributeIds as $atttibuteId) {
00138             $setInfo[$atttibuteId] = isset($attributeToSetInfo[$atttibuteId])
00139                 ? $attributeToSetInfo[$atttibuteId]
00140                 : array();
00141         }
00142 
00143         return $setInfo;
00144     }

validate ( object,
name 
)

Validate attribute set name

Parameters:
Mage_Eav_Model_Entity_Attribute_Set $object
string $name
Returns:
bool

Definition at line 83 of file Set.php.

00084     {
00085         $read = $this->_getReadAdapter();
00086         $select = $read->select()->from($this->getMainTable())
00087             ->where("attribute_set_name=?",$name)
00088             ->where("entity_type_id=?",$object->getEntityTypeId());
00089 
00090         if ($object->getId()) {
00091             $select->where("attribute_set_id!=?",$object->getId());
00092         }
00093 
00094         if (!$read->fetchOne($select)) {
00095            return true;
00096         }
00097 
00098         return false;
00099     }


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