本文整理汇总了PHP中Mage_Eav_Model_Entity_Setup::addEntityType方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Eav_Model_Entity_Setup::addEntityType方法的具体用法?PHP Mage_Eav_Model_Entity_Setup::addEntityType怎么用?PHP Mage_Eav_Model_Entity_Setup::addEntityType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Eav_Model_Entity_Setup
的用法示例。
在下文中一共展示了Mage_Eav_Model_Entity_Setup::addEntityType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addEntityType
/**
* Add an entity type
*
* If already exists updates the entity type with params data
*
* @param string $code
* @param array $params
* @return Mage_Eav_Model_Entity_Setup
* @throws Exception
*/
public function addEntityType($code, array $params)
{
$this->getConnection()->beginTransaction();
try {
$_updateMode = false;
if ($this->getEntityType($code, 'entity_type_id')) {
$_updateMode = true;
}
$params['entity_model'] = $this->_getValue($params, 'entity_model', sprintf('goodahead_etm/custom_%s_entity', $code));
$params['attribute_model'] = $this->_getValue($params, 'attribute_model', 'goodahead_etm/entity_attribute');
$params['table'] = $this->_getValue($params, 'table', 'goodahead_etm/entity');
$params['additional_attribute_table'] = $this->_getValue($params, 'additional_attribute_table', 'goodahead_etm/eav_attribute');
$params['entity_attribute_collection'] = $this->_getValue($params, 'entity_attribute_collection', 'goodahead_etm/entity_attribute_collection');
parent::addEntityType($code, $params);
$entityTypeId = $this->getEntityType($code, 'entity_type_id');
if ($entityTypeId) {
$data = array('entity_type_id' => $entityTypeId, 'entity_type_name' => $this->_getValue($params, 'entity_type_name', $code), 'default_attribute_id' => $this->_getValue($params, 'default_attribute_id'), 'entity_type_root_template' => $this->_getValue($params, 'entity_type_root_template'), 'entity_type_layout_xml' => $this->_getValue($params, 'entity_type_layout_xml'), 'entity_type_content' => $this->_getValue($params, 'entity_type_content'));
if ($_updateMode) {
unset($data['entity_type_id']);
$this->updateEntityTypeExtra($code, $data);
} else {
$this->_conn->insert($this->getTable('goodahead_etm/eav_entity_type'), $data);
}
if ($this->_getValue($params, 'create_system_attributes', false)) {
$this->addAttribute($entityTypeId, 'created_at', array('backend' => 'eav/entity_attribute_backend_time_created', 'type' => 'static', 'frontend' => 'eav/entity_attribute_frontend_datetime', 'input' => 'datetime', 'required' => false, 'label' => 'Created At', 'sort_order' => 1000));
$this->addAttribute($entityTypeId, 'updated_at', array('backend' => 'eav/entity_attribute_backend_time_updated', 'type' => 'static', 'frontend' => 'eav/entity_attribute_frontend_datetime', 'input' => 'datetime', 'required' => false, 'label' => 'Updated At', 'sort_order' => 1000));
}
}
$this->getConnection()->commit();
} catch (Exception $e) {
$this->getConnection()->rollBack();
throw $e;
}
return $this;
}