private function saveAttributeSet() { if ($this->attributeSetObj->getId()) { return array('result' => true, 'obj' => $this->attributeSetObj); } $this->attributeSetObj->setEntityTypeId($this->entityTypeId)->setAttributeSetName($this->setName); try { $this->attributeSetObj->validate(); $this->attributeSetObj->save(); $this->attributeSetObj->initFromSkeleton($this->skeletonId)->save(); } catch (Exception $e) { return array('result' => false, 'error' => $e->getMessage()); } return array('result' => true, 'obj' => $this->attributeSetObj); }
/** * Inherits all the attributes from the particular attribute set. * * @param Mage_Eav_Model_Entity_Attribute_Set $attributeSet * @param $inheritFromSetName */ private function _inheritAttributeSet(Mage_Eav_Model_Entity_Attribute_Set $attributeSet, $inheritFromSetName) { $entityTypeId = $this->_getEntityTypeId(); $inheritFromSetId = Mage::getResourceModel('eav/entity_attribute_set_collection')->addFieldToFilter('entity_type_id', $entityTypeId)->addFieldToFilter('attribute_set_name', $inheritFromSetName)->getFirstItem()->getId(); // Include some kind of failure check here $attributeSet->initFromSkeleton($inheritFromSetId)->save(); }