/** * Retrieve comma-separated list of entity registrant roles * * @param string $attributeCode * @param Enterprise_GiftRegistry_Model_Type $type * @return string */ public function getRegistrantRoles($attributeCode, $type) { if ($registrantRoles = $this->getEntity()->getRegistrantRoles()) { $roles = array(); foreach ($registrantRoles as $code) { if ($label = $type->getOptionLabel($attributeCode, $code)) { $roles[] = $label; } } if (count($roles)) { return implode(', ', $roles); } } return ''; }
/** * Get Entity type Name * @return string|null */ public function getTypeLabel() { if ($this->_type !== null) { return $this->_type->getLabel(); } return null; }
/** * 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(); } }
/** * Get attribute store data * * @param Enterprise_GiftRegistry_Model_Type $type * @return null|array */ public function getAttributesStoreData($type) { $select = $this->_getReadAdapter()->select()->from($this->_labelTable, array('attribute_code', 'option_code', 'label'))->where('type_id = :type_id')->where('store_id = :store_id'); $bind = array(':type_id' => (int) $type->getId(), ':store_id' => (int) $type->getStoreId()); return $this->_getReadAdapter()->fetchAll($select, $bind); }
/** * Validate Gift Registry Type before save * * @param Enterprise_GiftRegistry_Model_Type $model * @return void */ public function giftRegistryTypeSaveBefore($model) { // it's not allowed to create not form super user if (!$model->getId()) { $this->_throwSave(); } $model->setData(array('meta_xml' => $model->getOrigData('meta_xml'), 'code' => $model->getOrigData('model'))); }