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


PHP Mage_Eav_Model_Entity_Setup::getDefaultAttributeSetId方法代码示例

本文整理汇总了PHP中Mage_Eav_Model_Entity_Setup::getDefaultAttributeSetId方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Eav_Model_Entity_Setup::getDefaultAttributeSetId方法的具体用法?PHP Mage_Eav_Model_Entity_Setup::getDefaultAttributeSetId怎么用?PHP Mage_Eav_Model_Entity_Setup::getDefaultAttributeSetId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mage_Eav_Model_Entity_Setup的用法示例。


在下文中一共展示了Mage_Eav_Model_Entity_Setup::getDefaultAttributeSetId方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: array

<?php

$installer = $this;
$installer->startSetup();
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$entityTypeId = $setup->getEntityTypeId('customer');
$attributeSetId = $setup->getDefaultAttributeSetId($entityTypeId);
$attributeGroupId = $setup->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);
$installer->addAttribute("customer", "complete_sf_form", array("type" => "int", "backend" => "", "label" => "Completed SalesForce Form", "input" => "select", "source" => "eav/entity_attribute_source_boolean", "visible" => 1, "required" => 0, "default" => "0", "user_defined" => 1));
$attribute = Mage::getSingleton("eav/config")->getAttribute("customer", "complete_sf_form");
$setup->addAttributeToGroup($entityTypeId, $attributeSetId, $attributeGroupId, 'complete_sf_form', '999');
$used_in_forms = array();
$used_in_forms[] = "adminhtml_customer";
$attribute->setData("used_in_forms", $used_in_forms)->setData("is_used_for_customer_segment", true)->setData("is_system", 0)->setData("is_user_defined", 1)->setData("is_visible", 1)->setData("sort_order", 100);
$attribute->save();
$installer->endSetup();
开发者ID:greghoole,项目名称:magento_extensions,代码行数:16,代码来源:install-0.0.1.php

示例2: array

// 'air_flow'=>'Air Flow (m3/h)',
// 'noise_level'=>'Noise Level',
// 'speed'=>'Speed',
// 'control'=>'Control',
// 'filter'=>'Filter',
// 'finish'=>'Finish',
// 'timer'=>'Timer',
// 'no_of_lamps'=>'No.Of Lamps',
// 'burner'=>'Burner (no)',
// 'triple_ring_burner'=>'Triple Ring Burner',
// 'flat_burner'=>'Flat Burner',
// 'warranty'=>'Warranty',
// 'type'=>'Type',
// 'no_of_ways'=>'No.Of Ways',
// 'no_of_pin'=>'No.Of Pin',
// 'no_of_modules'=>'No.Of Modules',
// 'ampere'=>'Ampere',
// 'trap_type'=>'Trap Type',
Mage::app('default');
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
$installer = new Mage_Eav_Model_Entity_Setup('core_setup');
$entityTypeId = $installer->getEntityTypeId('catalog_product');
$attributeSetId = $installer->getDefaultAttributeSetId($entityTypeId);
$attributeGroupId = $installer->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);
foreach ($attributes as $key => $value) {
    try {
        $installer->addAttribute('catalog_product', $key, array('group' => 'Specification', 'type' => 'varchar', 'backend' => 'eav/entity_attribute_backend_array', 'frontend' => '', 'class' => '', 'default' => '', 'label' => $value, 'input' => 'text', 'source' => '', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, 'is_visible' => 1, 'required' => 0, 'searchable' => 1, 'filterable' => 0, 'unique' => 0, 'comparable' => 0, 'visible_on_front' => 1, 'user_defined' => 1));
    } catch (Exception $e) {
        echo $e->getMessage();
    }
}
开发者ID:mSupply,项目名称:runnable_test_repo,代码行数:31,代码来源:attribute_id_new.php

示例3: saveAction

 public function saveAction()
 {
     if ($data = $this->getRequest()->getPost()) {
         $setup = new Mage_Eav_Model_Entity_Setup('core_setup');
         $entityTypeId = $setup->getEntityTypeId('customer');
         $attributeSetId = $setup->getDefaultAttributeSetId($entityTypeId);
         $attributeGroupId = $setup->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);
         $attributeObject = Mage::getModel('customer/attribute');
         $attributeId = $this->getRequest()->getParam('id');
         $helper = Mage::helper('customerattribute');
         $attributeType = $attributeObject->load($attributeId)->getFrontendInput();
         if ($attributeId != null) {
             $data['frontend_input'] = $attributeType;
         }
         $data['validate_rules'] = $helper->getAttributeValidateRules1($data['frontend_input'], $data);
         if ($data['is_custom'] == 1 || $attributeId == 0) {
             if ($data['status'] == 1) {
                 if (in_array(1, $data['display_on_frontend'])) {
                     $data['used_in_forms'][] = 'customer_account_create';
                 }
                 if (in_array(2, $data['display_on_frontend'])) {
                     $data['used_in_forms'][] = 'customer_account_edit';
                 }
                 if ((in_array(3, $data['display_on_frontend']) || in_array(4, $data['display_on_frontend'])) && $attributeType != 'file' && $attributeType != 'image') {
                     $data['used_in_forms'][] = 'checkout_register';
                 }
                 if (in_array(1, $data['display_on_backend'])) {
                     $data['used_in_forms'][] = 'customer_Grid';
                 }
                 if (in_array(2, $data['display_on_backend'])) {
                     $data['used_in_forms'][] = 'order_grid';
                 }
                 if (in_array(3, $data['display_on_backend']) && $attributeType != 'file' && $attributeType != 'image') {
                     $data['used_in_forms'][] = 'adminhtml_checkout';
                 }
                 $data['used_in_forms'][] = 'tabCustomerattribute';
             } else {
                 $data['used_in_forms'][] = array();
             }
         }
         try {
             $data1 = array('status' => $data['status'], 'show_on_create_account' => (int) in_array(1, $data['display_on_frontend']), 'show_on_account_edit' => (int) in_array(2, $data['display_on_frontend']), 'show_on_checkout_register_customer' => (int) in_array(3, $data['display_on_frontend']), 'show_on_checkout_register_guest' => (int) in_array(4, $data['display_on_frontend']), 'show_on_grid_customer' => (int) in_array(1, $data['display_on_backend']), 'show_on_grid_order' => (int) in_array(2, $data['display_on_backend']), 'show_on_admin_checkout' => (int) in_array(3, $data['display_on_backend']), 'customer_group' => implode(", ", $data['customer_group']), 'store_id' => implode(", ", $data['store_view']));
             if ($attributeType == 'file' || $attributeType == 'image') {
                 $data1['show_on_checkout_register_customer'] = 0;
                 $data1['show_on_checkout_register_guest'] = 0;
                 $data1['show_on_admin_checkout'] = 0;
             }
             $model = Mage::getModel('customerattribute/customerattribute');
             if ($attributeId) {
                 $models = Mage::getModel('customerattribute/customerattribute')->getCollection()->addFieldToFilter('attribute_id', $attributeId)->getFirstItem();
                 $data1['attribute_id'] = $attributeId;
                 $attributeObject->load($attributeId)->addData($data);
                 $attributeObject->setId($attributeId)->save();
                 $model->load($models->getId())->setData($data1);
                 $model->setId($models->getId())->save();
                 Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('customerattribute')->__('The customer attribute has been saved.'));
             } else {
                 $data['attribute_code'] = str_replace(' ', '', $data['attribute_code']);
                 $data['attribute_code'] = strtolower($data['attribute_code']);
                 $defaultValueField = $helper->getAttributeDefaultValueByInput($data['frontend_input']);
                 if ($defaultValueField) {
                     $scopeKeyPrefix = $this->getRequest()->getParam('website') ? 'scope_' : '';
                     $data[$scopeKeyPrefix . 'default_value'] = $helper->stripTags($this->getRequest()->getParam($scopeKeyPrefix . $defaultValueField));
                 }
                 $data['entity_type_id'] = $entityTypeId;
                 $data['attribute_group_id'] = $attributeGroupId;
                 $data['attribute_set_id'] = $attributeSetId;
                 $data['backend_type'] = $helper->getAttributeBackendTypeByInputType($data['frontend_input']);
                 $data['backend_model'] = $helper->getAttributeBackendModelByInputType($data['frontend_input']);
                 $data['source_model'] = $helper->getAttributeSourceModelByInputType($data['frontend_input']);
                 $data['is_system'] = 0;
                 $data['is_user_defined'] = 1;
                 if ($data['frontend_input'] == 'date') {
                     $data['input_filter'] = 'date';
                 }
                 $attributeObject->setData($data);
                 $attributeId = $attributeObject->save()->getId();
                 $data1['is_custom'] = 1;
                 $data1['attribute_id'] = $attributeId;
                 $model->setData($data1)->save();
                 Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('customerattribute')->__('The customer customer attribute has been saved.'));
                 // Addcolumn to orderattribute table create by Hoatq
                 $table = new Mage_Core_Model_Resource_Setup();
                 $table->getConnection()->addColumn($table->getTable('orderattribute'), 'customer_' . $data['attribute_code'], 'varchar(255)');
             }
         } catch (Exception $e) {
             if (!$attributeId) {
                 $attributeCode = $data['attribute_code'];
                 $attributeObject = $this->_initAttribute()->loadByCode($this->_getEntityType()->getId(), $attributeCode);
                 if ($attributeObject->getId()) {
                     $this->_getSession()->addError(Mage::helper('customerattribute')->__('Attribute with the same code already exists'));
                 }
             } else {
                 Mage::getSingleton('adminhtml/session')->addError(Mage::helper('customerattribute')->__('Unable to find item to save'));
             }
         }
         if ($this->getRequest()->getParam('back', false)) {
             $this->_redirect('*/*/edit', array('id' => $attributeId, '_current' => true));
             return;
         } else {
//.........这里部分代码省略.........
开发者ID:technomagegithub,项目名称:inmed-magento,代码行数:101,代码来源:CustomerattributeController.php

示例4: array

<?php

/**
 * Dc_BrandManager
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 *
 * @category   Dc
 * @package    Dc_BrandManager
 * @copyright  Copyright (c) 2012-2015 Damián Culotta. (http://www.damianculotta.com.ar/)
 * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */
$installer = $this;
$installer->startSetup();
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$setup->addAttributeGroup(Mage_Catalog_Model_Category::ENTITY, 'Default', 'Extra Options', 10);
$_attribute_set_id = $setup->getDefaultAttributeSetId(Mage_Catalog_Model_Category::ENTITY);
$_attribute_group_id = $setup->getAttributeGroupId(Mage_Catalog_Model_Category::ENTITY, $_attribute_set_id, 'Extra Options');
$setup->addAttribute('catalog_category', 'brand_icon', array('type' => 'varchar', 'backend' => 'catalog/category_attribute_backend_image', 'frontend' => '', 'label' => 'Brand Icon', 'input' => 'image', 'class' => '', 'source' => '', 'global' => 0, 'visible' => 1, 'required' => 0, 'user_defined' => 1, 'default' => 0, 'searchable' => 0, 'filterable' => 0, 'comparable' => 0, 'visible_on_front' => 1, 'unique' => 0, 'position' => 1));
$setup->addAttributeToGroup(Mage_Catalog_Model_Category::ENTITY, $_attribute_set_id, $_attribute_group_id, 'brand_icon', '10');
$installer->endSetup();
开发者ID:perichus,项目名称:magento-dc-brandmanager,代码行数:25,代码来源:upgrade-0.1.0-0.2.0.php


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