/** * 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; } }
/** * 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'))); }