/** * Set type for Model using typeId * @param int $typeId * @return Enterprise_GiftRegistry_Model_Entity | false */ public function setTypeById($typeId) { $this->_typeId = (int) $typeId; $this->_type = Mage::getSingleton('enterprise_giftregistry/type'); $this->_type->setStoreId(Mage::app()->getStore()->getStoreId()); $this->setData('type_id', $typeId); $this->_type->load($this->_typeId); if ($this->_type->getId()) { $this->_attributes = $this->_type->getAttributes(); return $this; } else { return false; } }
/** * Convert attributes data to xml * * @param Enterprise_GiftRegistry_Model_Type $type * @return string */ public function processData($type) { if ($data = $type->getAttributes()) { $xmlObj = new Varien_Simplexml_Element('<config></config>'); $typeXml = $xmlObj->addChild(self::XML_PROTOTYPE_NODE); if (is_array($data)) { $groups = array(); foreach ($data as $attributes) { foreach ($attributes as $attribute) { if ($attribute['group'] == self::XML_REGISTRANT_NODE) { $group = self::XML_REGISTRANT_NODE; } else { $group = self::XML_REGISTRY_NODE; } $groups[$group][$attribute['code']] = $attribute; } } foreach ($groups as $group => $attributes) { $this->processDataType($typeXml, $group, $attributes); } } return $xmlObj->asNiceXml(); } }