本文整理汇总了PHP中Mage_Eav_Model_Entity_Setup::addAttribute方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Eav_Model_Entity_Setup::addAttribute方法的具体用法?PHP Mage_Eav_Model_Entity_Setup::addAttribute怎么用?PHP Mage_Eav_Model_Entity_Setup::addAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Eav_Model_Entity_Setup
的用法示例。
在下文中一共展示了Mage_Eav_Model_Entity_Setup::addAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addAttribute
public function addAttribute($entityTypeId, $code, array $attr)
{
if (isset($this->_flatEntityTables[$entityTypeId]) && $this->_flatTableExist($this->_flatEntityTables[$entityTypeId])) {
$this->_addFlatAttribute($this->_flatEntityTables[$entityTypeId], $code, $attr);
} else {
parent::addAttribute($entityTypeId, $code, $attr);
}
return $this;
}
示例2: catch
<?php
/** @var $this Mage_Core_Model_Resource_Setup */
$_installer = $this;
$_installer->startSetup();
$_setup = new Mage_Eav_Model_Entity_Setup('core_setup');
try {
$_setup->removeAttribute('catalog_product', 'allow_shipping');
} catch (Exception $_e) {
Mage::logException($_e);
}
$_setup->addAttribute(Mage_Catalog_Model_Product::ENTITY, 'allow_shipping', array('group' => 'Rental Shipping Method', 'type' => 'int', 'backend' => '', 'frontend' => '', 'label' => 'Customer can chose Shipping Method on Product Page', 'input' => 'select', 'source' => 'eav/entity_attribute_source_boolean', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'is_visible' => true, 'required' => false, 'user_defined' => true, 'default' => '', 'is_searchable' => false, 'is_filterable' => false, 'is_comparable' => false, 'is_visible_on_front' => true, 'is_visible_in_advanced_search' => false, 'is_used_in_product_listing' => false, 'unique' => false));
$_installer->endSetup();
示例3: array
* @package RewardsPoint2
* @copyright Copyright (c) 2009 J2T DESIGN. (http://www.j2t-design.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
$installer = $this;
$attributeInfoFb = Mage::getResourceModel('eav/entity_attribute_collection')->setCodeFilter('rewardsocial_facebook')->getFirstItem();
$attributeInfoGp = Mage::getResourceModel('eav/entity_attribute_collection')->setCodeFilter('rewardsocial_google')->getFirstItem();
$attributeInfoTt = Mage::getResourceModel('eav/entity_attribute_collection')->setCodeFilter('rewardsocial_twitter')->getFirstItem();
$entityTypeId = Mage::getModel('eav/entity')->setType('catalog_product')->getTypeId();
$attributeGroup = Mage::getResourceModel('eav/entity_attribute_set_collection')->addFieldToFilter('attribute_set_name', array('eq' => 'Default'))->addFieldToFilter('entity_type_id', array('eq' => $entityTypeId))->getFirstItem();
if (!$attributeGroup->getAttributeSetId()) {
$installer->addAttributeSet(Mage_Catalog_Model_Product::ENTITY, 'Default');
$attributeGroup = Mage::getResourceModel('eav/entity_attribute_set_collection')->addFieldToFilter('attribute_set_name', array('eq' => 'Default'))->addFieldToFilter('entity_type_id', array('eq' => $entityTypeId))->getFirstItem();
}
if (!$attributeInfoFb->getAttributeId() && !$attributeInfoGp->getAttributeId() && !$attributeInfoTt->getAttributeId() && $attributeGroup->getAttributeSetId()) {
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$installer->startSetup();
/**
* Adding Different Attributes
*/
// adding attribute group
$setup->addAttributeGroup('catalog_product', 'Default', 'J2T Reward Social', 1000);
$entityTypeId = $installer->getEntityTypeId('catalog_product');
$attributeSetId = $installer->getDefaultAttributeSetId($entityTypeId);
$attributeGroupId = $installer->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);
// the attribute added will be displayed under the group/tab Special Attributes in product edit page
$setup->addAttribute('catalog_product', 'rewardsocial_facebook', array('group' => 'J2T Reward Social', 'input' => 'text', 'type' => 'text', 'label' => 'Facebook Like Points', 'frontend_class' => 'validate-digits', 'backend' => '', 'visible' => 1, 'required' => 0, 'user_defined' => 0, 'searchable' => 0, 'filterable' => 0, 'comparable' => 0, 'visible_on_front' => 0, 'visible_in_advanced_search' => 0, 'is_html_allowed_on_front' => 0, 'used_in_product_listing' => true, 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL));
$setup->addAttribute('catalog_product', 'rewardsocial_google', array('group' => 'J2T Reward Social', 'input' => 'text', 'type' => 'text', 'label' => 'Google + Points', 'frontend_class' => 'validate-digits', 'backend' => '', 'visible' => 1, 'required' => 0, 'user_defined' => 0, 'searchable' => 0, 'filterable' => 0, 'comparable' => 0, 'visible_on_front' => 0, 'visible_in_advanced_search' => 0, 'is_html_allowed_on_front' => 0, 'used_in_product_listing' => true, 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL));
$setup->addAttribute('catalog_product', 'rewardsocial_twitter', array('group' => 'J2T Reward Social', 'input' => 'text', 'type' => 'text', 'label' => 'Twitter Share Points', 'frontend_class' => 'validate-digits', 'backend' => '', 'visible' => 1, 'required' => 0, 'user_defined' => 0, 'searchable' => 0, 'filterable' => 0, 'comparable' => 0, 'visible_on_front' => 0, 'visible_in_advanced_search' => 0, 'is_html_allowed_on_front' => 0, 'used_in_product_listing' => true, 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL));
$installer->endSetup();
}
示例4: array
* on any other Magento edition except Magento enterprise edition.
* aheadWorks does not provide extension support in case of
* incorrect edition usage.
* =================================================================
*
* @category AW
* @package AW_Onsale
* @version 2.4.0
* @copyright Copyright (c) 2010-2012 aheadWorks Co. (http://www.aheadworks.com)
* @license http://ecommerce.aheadworks.com/AW-LICENSE.txt
*/
$installer = $this;
$installer->startSetup();
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$setup->removeAttribute('catalog_product', 'aw_os_product_display');
$setup->removeAttribute('catalog_product', 'aw_os_product_position');
$setup->removeAttribute('catalog_product', 'aw_os_product_image');
$setup->removeAttribute('catalog_product', 'aw_os_product_text');
$setup->removeAttribute('catalog_product', 'aw_os_category_display');
$setup->removeAttribute('catalog_product', 'aw_os_category_position');
$setup->removeAttribute('catalog_product', 'aw_os_category_image');
$setup->removeAttribute('catalog_product', 'aw_os_category_text');
$setup->addAttribute('catalog_product', 'aw_os_product_display', array('backend' => 'onsale/entity_attribute_backend_boolean_config', 'source' => 'onsale/entity_attribute_source_boolean_config', 'label' => 'Display', 'group' => 'Product Label', 'input' => 'select', 'class' => 'validate-digit', 'global' => true, 'visible' => true, 'required' => true, 'user_defined' => false, 'default' => '0', 'visible_on_front' => false));
$setup->addAttribute('catalog_product', 'aw_os_product_position', array('backend' => 'onsale/entity_attribute_backend_position', 'source' => 'onsale/entity_attribute_source_position', 'label' => 'Position', 'group' => 'Product Label', 'input' => 'select', 'class' => 'validate-digit', 'global' => true, 'visible' => true, 'required' => true, 'user_defined' => false, 'default' => 'BR', 'visible_on_front' => false));
$setup->addAttribute('catalog_product', 'aw_os_product_image', array('backend' => 'onsale/entity_attribute_backend_image', 'label' => 'Image', 'group' => 'Product Label', 'input' => 'image', 'class' => 'validate-digit', 'global' => true, 'visible' => true, 'required' => false, 'user_defined' => false, 'default' => '', 'visible_on_front' => false));
$setup->addAttribute('catalog_product', 'aw_os_product_text', array('source' => 'onsale/entity_attribute_source_text', 'group' => 'Product Label', 'label' => 'Text', 'note' => 'You can use predefined values in this field. Please refer to extension manual.', 'input' => 'text', 'class' => '', 'global' => true, 'visible' => true, 'required' => false, 'user_defined' => false, 'default' => 'CUSTOM', 'visible_on_front' => false));
$setup->addAttribute('catalog_product', 'aw_os_category_display', array('backend' => 'onsale/entity_attribute_backend_boolean_config', 'source' => 'onsale/entity_attribute_source_boolean_config', 'label' => 'Display', 'group' => 'Category Label', 'input' => 'select', 'class' => 'validate-digit', 'global' => true, 'visible' => true, 'required' => true, 'user_defined' => false, 'default' => '0', 'visible_on_front' => false));
$setup->addAttribute('catalog_product', 'aw_os_category_position', array('backend' => 'onsale/entity_attribute_backend_position', 'source' => 'onsale/entity_attribute_source_position', 'label' => 'Position', 'group' => 'Category Label', 'input' => 'select', 'class' => 'validate-digit', 'global' => true, 'visible' => true, 'required' => true, 'user_defined' => false, 'default' => 'BR', 'visible_on_front' => false));
$setup->addAttribute('catalog_product', 'aw_os_category_image', array('backend' => 'onsale/entity_attribute_backend_image', 'label' => 'Image', 'group' => 'Category Label', 'input' => 'image', 'class' => 'validate-digit', 'global' => true, 'visible' => true, 'required' => false, 'user_defined' => false, 'default' => '', 'visible_on_front' => false));
$setup->addAttribute('catalog_product', 'aw_os_category_text', array('source' => 'onsale/entity_attribute_source_text', 'group' => 'Category Label', 'label' => 'Text', 'note' => 'You can use predefined values in this field. Please refer to extension manual.', 'input' => 'text', 'class' => '', 'global' => true, 'visible' => true, 'required' => false, 'user_defined' => false, 'default' => 'CUSTOM', 'visible_on_front' => false));
$installer->endSetup();
示例5: array
<?php
/**
* Pan_JewelryDesigner Extension
*
* @category Pan
* @package Pan_JewelryDesigner
* @copyright Copyright (c) 2014 August Ash, Inc. (http://www.augustash.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @author August Ash Team <core@augustash.com>
*/
$installer = new Mage_Eav_Model_Entity_Setup();
// start transaction
$installer->startSetup();
/**
* Is Dangle Charm (is_dangle_charm)
*
* Helps identify beads that are "danglers" b/c their
* registration point should be closer to the top than
* the center of the image
*/
$installer->addAttribute(Mage_Catalog_Model_Product::ENTITY, 'is_dangle_charm', array('group' => 'Jewelry Designer', 'input' => 'boolean', 'label' => 'Is Dangle Charm?', 'visible' => true, 'required' => false, 'visible_on_front' => false, 'user_defined' => true, 'default_value' => false, 'used_in_product_listing' => true, 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL));
/**
* Bracelet has spots for clips? (bracelet_has_clip_spots)
*
* Helps identify bracelets that may not have spots for clips
* and therefore do not have exclusion zones
*/
$installer->addAttribute(Mage_Catalog_Model_Product::ENTITY, 'bracelet_has_clip_spots', array('group' => 'Jewelry Designer', 'input' => 'boolean', 'label' => 'Bracelet has spots for clips?', 'visible' => true, 'required' => false, 'visible_on_front' => false, 'user_defined' => true, 'default_value' => true, 'used_in_product_listing' => true, 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL));
// end transaction
$installer->endSetup();
示例6: array
<?php
/**
* Mirasvit
*
* This source file is subject to the Mirasvit Software License, which is available at http://mirasvit.com/license/.
* Do not edit or add to this file if you wish to upgrade the to newer versions in the future.
* If you wish to customize this module for your needs
* Please refer to http://www.magentocommerce.com for more information.
*
* @category Mirasvit
* @package Sphinx Search Ultimate
* @version 2.3.1
* @revision 602
* @copyright Copyright (C) 2013 Mirasvit (http://mirasvit.com/)
*/
//2.2.9 - 2.2.9.1
$installer = $this;
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$installer->startSetup();
try {
$setup->addAttribute('catalog_category', 'searchindex_weight', array('group' => 'General Information', 'input' => 'text', 'type' => 'text', 'label' => 'Search Weight', 'backend' => '', 'visible' => 1, 'required' => 0, 'user_defined' => 1, 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE));
$setup->addAttribute('catalog_product', 'searchindex_weight', array('group' => 'General', 'input' => 'text', 'type' => 'text', 'label' => 'Search Weight', 'backend' => '', 'visible' => 1, 'required' => 0, 'user_defined' => 1, 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE));
} catch (Exception $e) {
Mage::logException($e);
}
$installer->endSetup();
示例7: testAction
public function testAction()
{
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$entity_type = Mage::getSingleton("eav/entity_type")->loadByCode("catalog_product");
$entity_type_id = $entity_type->getId();
$collection = Mage::getModel("eav/entity_attribute")->getCollection()->addFieldToFilter("entity_type_id", $entity_type_id)->addFieldToFilter("attribute_code", "giftwrap");
if (count($collection)) {
$collection->getFirstItem()->delete();
}
if (!count($collection)) {
$data = array('group' => 'General', 'type' => 'int', 'input' => 'select', 'label' => 'Wrappable', 'backend' => '', 'frontend' => '', 'source' => 'giftwrap/attribute_wrappable', 'visible' => 1, 'required' => 1, 'user_defined' => 1, 'is_searchable' => 1, 'is_filterable' => 0, 'is_comparable' => 1, 'is_visible_on_front' => 0, 'is_visible_in_advanced_search' => 1, 'used_for_sort_by' => 0, 'used_in_product_listing' => 1, 'used_for_price_rules' => 1, 'is_used_for_promo_rules' => 1, 'position' => 2, 'unique' => 0, 'is_configurable' => 1, 'default' => 0, 'is_global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE);
$setup->addAttribute('catalog_product', 'giftwrap', $data);
$entity_type_id = $setup->getEntityTypeId('catalog_product');
$data['entity_type_id'] = $entity_type_id;
$attribute = Mage::getModel("eav/entity_attribute")->setData($data)->setId($setup->getAttributeId('catalog_product', 'giftwrap'));
$attribute->save();
}
}
示例8: array
/**
* aheadWorks Co.
*
* NOTICE OF LICENSE
*
* This source file is subject to the EULA
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://ecommerce.aheadworks.com/AW-LICENSE.txt
*
* =================================================================
* MAGENTO EDITION USAGE NOTICE
* =================================================================
* This package designed for Magento COMMUNITY edition
* aheadWorks does not guarantee correct work of this extension
* on any other Magento edition except Magento COMMUNITY edition.
* aheadWorks does not provide extension support in case of
* incorrect edition usage.
* =================================================================
*
* @category AW
* @package AW_Ajaxcartpro
* @version 3.0.0
* @copyright Copyright (c) 2010-2012 aheadWorks Co. (http://www.aheadworks.com)
* @license http://ecommerce.aheadworks.com/AW-LICENSE.txt
*/
$installer = $this;
$installer->startSetup();
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$setup->addAttribute('catalog_product', 'aw_acp_disabled', array('backend' => 'giftmessage/entity_attribute_backend_boolean_config', 'input' => 'select', 'label' => 'Disable Ajax Cart Pro for that product', 'source' => 'eav/entity_attribute_source_boolean', 'required' => false, 'entity_model' => 'catalog/product', 'group' => 'ACP Options', 'global' => true, 'visible' => true, 'user_defined' => false, 'default' => '0', 'visible_on_front' => false));
$installer->endSetup();
示例9: array
<?php
$installer = $this;
$installer->startSetup();
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$setup->addAttribute('catalog_product', 'cjm_imageswitcher', array('group' => 'Images', 'input' => 'text', 'type' => 'text', 'label' => 'Image Switch Code', 'backend' => '', 'frontend' => '', 'visible' => false, 'required' => false, 'user_defined' => false, 'searchable' => false, 'filterable' => false, 'comparable' => false, 'visible_on_front' => false, 'visible_in_advanced_search' => false, 'is_html_allowed_on_front' => false, 'apply_to' => 'configurable', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, 'note' => 'Do Not Edit!'));
$setup->addAttribute('catalog_product', 'cjm_moreviews', array('group' => 'Images', 'input' => 'text', 'type' => 'text', 'label' => 'More Views Code', 'backend' => '', 'frontend' => '', 'visible' => false, 'required' => false, 'user_defined' => false, 'searchable' => false, 'filterable' => false, 'comparable' => false, 'visible_on_front' => false, 'visible_in_advanced_search' => false, 'is_html_allowed_on_front' => false, 'apply_to' => 'configurable', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, 'note' => 'Do Not Edit!'));
$tableName = Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_media_gallery_value');
$installer->run("ALTER TABLE `" . $tableName . "` ADD `defaultimg` TINYINT( 4 ) UNSIGNED NOT NULL DEFAULT '0'");
$installer->endSetup();
示例10: array
<?php
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$setup->addAttribute('order', 'mw_customercomment', array('label' => 'Customer Comment', 'type' => 'text', 'input' => 'text', 'visible' => true, 'required' => false, 'position' => 1));
示例11: array
<?php
$this->startSetup();
$this->run('');
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$setup->addAttribute(Mage_Catalog_Model_Category::ENTITY, Vikont_Fitment_Helper_Data::ARI_ACTIVITY_ATTRIBUTE_CODE, array('group' => 'ARI', 'type' => 'int', 'label' => 'ARI activity', 'input' => 'select', 'source' => 'fitment/source_ari_activity', 'backend' => '', 'visible' => true, 'required' => false, 'visible_on_front' => false, 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'note' => ''));
$this->endSetup();
示例12: array
<?php
$installer = $this;
$installer->startSetup();
$newFields = array('delivery_datetime' => array('type' => 'datetime', 'required' => 0, 'input' => 'text', 'default' => ''));
$order = Mage::getModel('sales/order');
$entityType = $order->getResource()->getEntityType();
$entityTypeId = $entityType->getId();
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
foreach ($newFields as $attributeName => $attributeDefs) {
$setup->addAttribute($entityTypeId, $attributeName, array('position' => 1, 'type' => $attributeDefs['type'], 'required' => $attributeDefs['required'], 'input' => $attributeDefs['input'], 'default' => $attributeDefs['default']));
}
$installer->endSetup();
示例13: array
<?php
$installer = $this;
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$installer->startSetup();
$setup->removeAttribute('catalog_product', 'use_manufacturer_part_no');
$setup->addAttribute('catalog_product', 'use_manufacturer_part_no', array('group' => 'General', 'input' => 'select', 'type' => 'int', 'label' => 'Use Manufacturer Part No.', 'source' => 'eav/entity_attribute_source_boolean', 'backend' => 'eav/entity_attribute_backend_array', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'visible' => true, 'required' => false, 'default_value' => '0'));
$installer->endSetup();
示例14: array
<?php
$installer = $this;
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$installer->startSetup();
$setup->addAttribute('catalog_product', 'unm_disable_add_to_cart', array('group' => 'General', 'input' => 'select', 'type' => 'int', 'label' => 'Disable Add To Cart', 'source' => 'eav/entity_attribute_source_boolean', 'backend' => 'eav/entity_attribute_backend_array', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'visible' => true, 'required' => false, 'default_value' => '0'));
$installer->endSetup();
示例15: array
<?php
$installer = $this;
$installer->startSetup();
// ========================================
// criacao dos atributos dos produtos
// ========================================
if (Mage::getVersion() >= 1.5) {
$setup = Mage::getModel('catalog/resource_setup', 'core_setup');
} else {
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
}
$setup->addAttribute('catalog_product', 'novaPontoCom_importError', array('type' => 'text', 'backend' => '', 'frontend' => '', 'label' => 'Import Error - NovaPontoCom', 'input' => 'text', 'class' => '', 'source' => '', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'visible' => false, 'required' => false, 'user_defined' => false, 'default' => '', 'searchable' => false, 'filterable' => false, 'comparable' => false, 'visible_on_front' => false, 'unique' => false, 'apply_to' => 'simple,bundle,grouped,configurable', 'is_configurable' => false));
$installer->endSetup();