当前位置: 首页>>代码示例>>PHP>>正文


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怎么用?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;
 }
开发者ID:eniuz,项目名称:entitytype-manager,代码行数:45,代码来源:Setup.php


注:本文中的Mage_Eav_Model_Entity_Setup::addEntityType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。