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


PHP Mage_Eav_Model_Entity_Setup::getAttributeId方法代码示例

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


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

示例1: _addAttributeToAttributeSet

 protected function _addAttributeToAttributeSet($attributeSetId, $attributeCode)
 {
     $setup = new \Mage_Eav_Model_Entity_Setup('core_setup');
     $attributeId = $setup->getAttributeId('catalog_product', $attributeCode);
     $attributeGroupId = $setup->getDefaultAttributeGroupId('catalog_product', $attributeSetId);
     $setup->addAttributeToSet('catalog_product', $attributeSetId, $attributeGroupId, $attributeId);
 }
开发者ID:eniuz,项目名称:EAVCleaner,代码行数:7,代码来源:MessdataCommand.php

示例2: array

 */
/** @var $installer Mage_Core_Model_Resource_Setup */
$installer = $this;
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$installer->startSetup();
/* Add credit value attribute */
$data = array('type' => 'decimal', 'input' => 'text', 'label' => 'Credit Balance', 'backend' => '', 'frontend' => '', 'source' => '', 'is_visible' => 0, 'is_visible_on_front' => 0, 'required' => 0, 'user_defined' => 0, 'is_searchable' => 1, 'is_filterable' => 0, 'is_comparable' => 0, 'position' => 2, 'unique' => 0, 'default' => 0.0, 'is_global' => '');
$setup->addAttribute('customer', 'credit_value', $data);
$attribute = Mage::getSingleton('eav/config')->getAttribute('customer', 'credit_value');
$attribute->setDefaultValue('0.00');
$attribute->save();
$setup->removeAttribute('catalog_product', 'credit_amount');
$attr = array('group' => 'Prices', 'type' => 'text', 'input' => 'text', 'label' => 'Credit Amount', 'backend' => '', 'frontend' => '', 'source' => '', 'visible' => 1, 'user_defined' => 1, 'used_for_price_rules' => 1, 'position' => 2, 'unique' => 0, 'default' => '', 'sort_order' => 101, 'note' => 'For example:
                        <br/>Fixed price: 100 
                        <br/>Option Price: 10,20,30 
                        <br/>Price range: 1-100
                        ');
$setup->addAttribute('catalog_product', 'credit_amount', $attr);
$creditAmount = Mage::getModel('catalog/resource_eav_attribute')->load($setup->getAttributeId('catalog_product', 'credit_amount'));
$creditAmount->addData(array('is_global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, 'is_required' => 0, 'apply_to' => array('customercredit'), 'is_configurable' => 1, 'is_searchable' => 1, 'is_visible_in_advanced_search' => 1, 'is_comparable' => 0, 'is_filterable' => 0, 'is_filterable_in_search' => 1, 'is_used_for_promo_rules' => 1, 'is_html_allowed_on_front' => 0, 'is_visible_on_front' => 0, 'used_in_product_listing' => 1, 'used_for_sort_by' => 0, 'backend_type' => 'text'))->save();
$tax = Mage::getModel('catalog/resource_eav_attribute')->load($setup->getAttributeId('catalog_product', 'tax_class_id'));
$applyTo = explode(',', $tax->getData('apply_to'));
$applyTo[] = 'customercredit';
$tax->addData(array('apply_to' => $applyTo))->save();
/**
 * create customercredit table
 */
$installer->run("\nDROP TABLE IF EXISTS {$this->getTable('credit_transaction')};\nDROP TABLE IF EXISTS {$this->getTable('credit_code')};\nDROP TABLE IF EXISTS {$this->getTable('type_transaction')};\n\t\nCREATE TABLE {$this->getTable('credit_transaction')} (\n  `transaction_id` int(10) unsigned NOT NULL auto_increment,\n  `customer_id` int(10) unsigned NOT NULL ,\n  `type_transaction_id` int(11) NULL,\n  `detail_transaction` varchar(255)  NULL default '',\n  `order_increment_id` varchar(30) NULL default '',\n  `amount_credit` decimal(12,4) default '0',\n  `begin_balance` decimal(12,4) default '0',\n  `end_balance` decimal(12,4) default '0',\n  `transaction_time` datetime NULL,\n  `customer_group_ids` int(10) default '0',\n  `status` varchar(20) default '',\n  `spent_credit` decimal(12,4) NOT NULL,\n  `received_credit` decimal(12,4) NOT NULL,\n  PRIMARY KEY (`transaction_id`),\n  INDEX (`customer_id`),\n  FOREIGN KEY (`customer_id`)\n  REFERENCES {$this->getTable('customer_entity')} (`entity_id`)\n  ON DELETE CASCADE\n  ON UPDATE CASCADE\n) ENGINE=InnoDB DEFAULT CHARSET=utf8;\n\nCREATE TABLE {$this->getTable('credit_code')} (\n  `credit_code_id` int(11) unsigned NOT NULL auto_increment,\n  `credit_code` varchar(255) NOT NULL default '',\n  `currency` varchar(45) default '',\n  `description` text default '',\n  `transaction_time` datetime NULL,\n  `status` varchar(20) default '',\n  `amount_credit` decimal(12,4) default '0',\n  `recipient_email` varchar(200) default '',\n  `customer_id` int(10) unsigned NOT NULL ,\n  PRIMARY KEY (`credit_code_id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8;\n\nCREATE TABLE {$this->getTable('type_transaction')} (\n  `type_transaction_id` int(11) unsigned NOT NULL auto_increment,\n  `transaction_name` varchar(255) default '',\n  PRIMARY KEY (`type_transaction_id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8;\n\n\nINSERT  INTO {$this->getTable('type_transaction')}(`type_transaction_id`,`transaction_name`) \nVALUES  (1,'Changed by admin'),\n        (2,'Send credit to friends'),\n        (3,'Receive Credit from Friends'),\n        (4,'Redeem Credit'),\n        (5,'Receive order refund by credit'),\n        (6,'Check Out by Credit'),\n        (7,'Cancel sending credit'),\n        (8,'Customer Buy Credit'),\n        (9,'Cancel Order'),\n        (10,'Refund Credit Product')\n;\n\n");
$installer->getConnection()->addColumn($installer->getTable('sales/order'), 'customercredit_discount', 'decimal(12,4) NULL');
$installer->getConnection()->addColumn($installer->getTable('sales/order'), 'base_customercredit_discount', 'decimal(12,4) NULL');
$installer->endSetup();
开发者ID:javik223,项目名称:Evron-Magento,代码行数:31,代码来源:mysql4-install-0.1.0.php

示例3: array

<?php

/**
 * @author Amasty Team
 * @copyright Copyright (c) 2015 Amasty (https://www.amasty.com)
 * @package Amasty_Xnotif
 */
$installer = new Mage_Eav_Model_Entity_Setup($this->_resourceName);
$installer->startSetup();
$installer->addAttribute('catalog_product', 'amxnotif_hide_alert', array('type' => 'int', 'backend' => '', 'frontend' => '', 'label' => 'Hide Stock Alert Block', 'input' => 'select', 'class' => '', 'source' => 'eav/entity_attribute_source_boolean', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'visible' => true, 'required' => false, 'user_defined' => false, 'default' => '', 'searchable' => false, 'filterable' => false, 'comparable' => false, 'visible_on_front' => false, 'unique' => false, 'is_configurable' => false));
$attributeId = $installer->getAttributeId('catalog_product', 'amxnotif_hide_alert');
foreach ($installer->getAllAttributeSetIds('catalog_product') as $attributeSetId) {
    try {
        $attributeGroupId = $installer->getAttributeGroupId('catalog_product', $attributeSetId, 'General');
    } catch (Exception $e) {
        $attributeGroupId = $installer->getDefaultAttributeGroupId('catalog_product', $attributeSetId);
    }
    $installer->addAttributeToSet('catalog_product', $attributeSetId, $attributeGroupId, $attributeId);
}
$installer->endSetup();
开发者ID:santhosh400,项目名称:ecart,代码行数:20,代码来源:mysql4-upgrade-1.1.1-1.1.2.php

示例4:

<?php

require_once "mygassi-config.php";
require_once mageroot;
Mage::app();
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$setup->startSetup();
$setup->deleteTableRow('eav/entity_attribute', 'attribute_id', $setup->getAttributeId('catalog_product', 'linientext'), 'attribute_set_id', $setup->getAttributeSetId('catalog_product', 'Default'));
$setup->deleteTableRow('eav/entity_attribute', 'attribute_id', $setup->getAttributeId('catalog_product', 'gruppentext'), 'attribute_set_id', $setup->getAttributeSetId('catalog_product', 'Default'));
$setup->deleteTableRow('eav/entity_attribute', 'attribute_id', $setup->getAttributeId('catalog_product', 'einzeltext'), 'attribute_set_id', $setup->getAttributeSetId('catalog_product', 'Default'));
$setup->deleteTableRow('eav/entity_attribute', 'attribute_id', $setup->getAttributeId('catalog_product', 'add_desc_1'), 'attribute_set_id', $setup->getAttributeSetId('catalog_product', 'Default'));
$setup->deleteTableRow('eav/entity_attribute', 'attribute_id', $setup->getAttributeId('catalog_product', 'add_desc_2'), 'attribute_set_id', $setup->getAttributeSetId('catalog_product', 'Default'));
$setup->deleteTableRow('eav/entity_attribute', 'attribute_id', $setup->getAttributeId('catalog_product', 'add_desc_3'), 'attribute_set_id', $setup->getAttributeSetId('catalog_product', 'Default'));
$setup->endSetup();
exit;
开发者ID:vberzsin,项目名称:shop,代码行数:15,代码来源:fix.php

示例5: int

<?php

$installer = $this;
$installer->startSetup();
$installer->run("\n\nDROP TABLE IF EXISTS {$this->getTable('aramex_shipping_suppliers')};\nCREATE TABLE {$this->getTable('aramex_shipping_suppliers')} (\n  `asv_id` int(11) unsigned NOT NULL auto_increment,\n  `identifier` varchar(255) NOT NULL,\n  `username` varchar(255) NOT NULL,\n  `password` varchar(255) NOT NULL,\n  `account_country_code` varchar(2) NULL,\n  `account_entity` varchar(3) NULL,\n  `account_number` int(11) unsigned NULL,\n  `account_pin` int(11) unsigned NULL,\n  `address_line1` varchar(255) NOT NULL,\n  `address_line2` varchar(255) NULL,\n  `address_line3` varchar(255) NULL,\n  `city` varchar(255) NOT NULL,\n  `state_or_province_code` varchar(255) NULL,\n  `post_code` varchar(255) NOT NULL,\n  `country_code` varchar(2) NOT NULL,\n  `department` varchar(255) NULL,\n  `person_name` varchar(255) NOT NULL,\n  `person_title` varchar(255) NULL,\n  `company_name` varchar(255) NOT NULL,\n  `phone_number1` varchar(255) NOT NULL,\n  `phone_number1_ext` varchar(255) NOT NULL,\n  `phone_number2` varchar(255) NULL,\n  `phone_number2_ext` varchar(255) NULL,\n  `fax_number` varchar(255) NULL,\n  `cellphone` varchar(255) NOT NULL,\n  `email` varchar(255) NOT NULL,\n  `type` varchar(255) NULL,\n  PRIMARY KEY (`asv_id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8;\n\n    ");
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
if (!$setup->getAttributeId(Mage_Catalog_Model_Product::ENTITY, 'aramex_supplier')) {
    $setup->addAttribute('catalog_product', 'aramex_supplier', array('attribute_set' => 'Default', 'group' => 'General', 'input' => 'select', 'type' => 'text', 'label' => 'Aramex Supplier', 'backend' => '', 'visible' => 1, 'required' => 0, 'user_defined' => 1, 'searchable' => 1, 'filterable' => 0, 'comparable' => 1, 'visible_on_front' => 1, 'visible_in_advanced_search' => 0, 'is_html_allowed_on_front' => 0, 'source' => 'aramexshipping/product_attribute_source_suppliers', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL));
}
if (version_compare(Mage::getVersion(), '1.4.1.0', '>=')) {
    $setup = $this->_conn;
    $setup->addColumn($this->getTable('sales_flat_shipment'), 'aramex_shipment_data', 'text');
} else {
    $setup = new Mage_Eav_Model_Entity_Setup('sales_setup');
    $setup->addAttribute('shipment', 'aramex_shipment_data', array('type' => 'text'));
}
$installer->endSetup();
开发者ID:TusharKDonda,项目名称:maruti,代码行数:17,代码来源:mysql4-install-1.0.0.php

示例6: array

<?php

$installer = $this;
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$catalogProduct = 'catalog_product';
$attributeCode = 'ism_newstoremembers_price';
$setup->addAttribute($catalogProduct, $attribute_code, array('input' => 'text', 'label' => 'Newstore Member Price', 'backend' => '', 'frontend_class' => 'validate-number', 'visible' => 1, 'required' => 0, 'user_defined' => 1, 'searchable' => 0, 'filterable' => 0, 'sort_order' => 30, 'comparable' => 0, 'visible_on_front' => 0, 'visible_in_advanced_search' => 0, 'is_html_allowed_on_front' => 0, 'is_configurable' => 1, 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL));
//add new attribute in prices attribute set
$groupName = 'prices';
$attributeSetName = 'default';
$attributeSetId = $setup->getAttributeSetId($catalogProduct, $attributeSetName);
$attributeGroupId = $setup->getAttributeGroupId($catalogProduct, $attributeSetId, $groupName);
$attributeId = $setup->getAttributeId($catalogProduct, $attributeCode);
$setup->addAttributeToSet($catalogProduct, $attributeSetId, $attributeGroupId, $attributeId);
$installer->endSetup();
$group = Mage::getModel('customer/group')->setData(array('customer_group_code' => 'Newstore Members Group', 'tax_class' => 3))->save();
Mage::getModel('core/config')->saveConfig('ism_newstore_members/newstore_members_group', "0", 'defaut', $group->getId());
开发者ID:swnsma,项目名称:practice,代码行数:17,代码来源:data-install-0.1.0.php

示例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();
     }
 }
开发者ID:AleksNesh,项目名称:pandora,代码行数:18,代码来源:IndexController.php

示例8:

<?php

$installer = $this;
$installer = new Mage_Eav_Model_Entity_Setup('core_setup');
$attribute_set_name = 'default';
$group_name = 'General';
$attribute_code = 'salepages';
$attribute_set_id = $installer->getAttributeSetId('catalog_product', $attribute_set_name);
$attribute_group_id = $installer->getAttributeGroupId('catalog_product', $attribute_set_id, $group_name);
$attribute_id = $installer->getAttributeId('catalog_product', $attribute_code);
$installer->addAttributeToSet($entityTypeId = 'catalog_product', $attribute_set_id, $attribute_group_id, $attribute_id);
$installer->endSetup();
开发者ID:shebin512,项目名称:Magento_Zoff,代码行数:12,代码来源:mysql4-upgrade-0.1.1-0.1.2.php

示例9: array

<?php

/**
 * @author Amasty Team
 * @copyright Copyright (c) 2015 Amasty (https://www.amasty.com)
 * @package Amasty_Conf
 */
$installer = new Mage_Eav_Model_Entity_Setup($this->_resourceName);
$installer->startSetup();
$installer->addAttribute('catalog_product', 'amconf_simple_price', array('type' => 'int', 'backend' => '', 'frontend' => '', 'label' => 'Use price of simple products', 'note' => 'If set to "Yes", full price of associated products of configurables is used for calculations and front end display instead of price difference.', 'input' => 'select', 'class' => '', 'source' => 'eav/entity_attribute_source_boolean', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'visible' => true, 'required' => false, 'user_defined' => false, 'default' => '', 'searchable' => false, 'filterable' => false, 'comparable' => false, 'visible_on_front' => false, 'unique' => false, 'apply_to' => 'configurable', 'is_configurable' => false));
$attributeId = $installer->getAttributeId('catalog_product', 'amconf_simple_price');
foreach ($installer->getAllAttributeSetIds('catalog_product') as $attributeSetId) {
    try {
        $attributeGroupId = $installer->getAttributeGroupId('catalog_product', $attributeSetId, 'General');
    } catch (Exception $e) {
        $attributeGroupId = $installer->getDefaultAttributeGroupId('catalog_product', $attributeSetId);
    }
    $installer->addAttributeToSet('catalog_product', $attributeSetId, $attributeGroupId, $attributeId);
}
$installer->endSetup();
开发者ID:rcclaudrey,项目名称:dev,代码行数:20,代码来源:mysql4-upgrade-3.5.8-3.6.0.php

示例10: array

<?php

$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$installer = $this;
$installer->startSetup();
//Giftwrap attribute
$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)) {
    $data = array('group' => 'General', 'type' => 'int', 'input' => 'select', 'label' => 'Wrappable', 'apply_to' => 'simple,bundle,configurable', '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();
}
$installer->run("\r\n\r\n\tALTER TABLE {$this->getTable('sales_flat_order')} ADD `giftwrap_amount` DECIMAL( 12, 4 ) ;\r\n\r\n\tALTER TABLE {$this->getTable('sales_flat_order')} ADD `giftwrap_tax` DECIMAL( 12, 4 ) NOT NULL default '0';\r\n\t\r\n\tDROP TABLE IF EXISTS {$this->getTable('giftwrap')};\r\n\tCREATE TABLE {$this->getTable('giftwrap')} (\r\n\t  `giftwrap_id` int(11) unsigned NOT NULL auto_increment,\r\n\t  `title` varchar(255) NOT NULL default '',\r\n\t  `price` DECIMAL(12,4) NOT NULL default '0',\r\n\t  `image` varchar(255) NULL default '',\r\n\t  `sort_order` int(10) NOT NULL default '0',  \r\n\t  `personal_message` smallint(6) NOT NULL default '0',\r\n\t  `status` smallint(6) NOT NULL default '0',\r\n\t  `character` int(10) NOT NULL default '0',\r\n\t  `store_id` smallint(5) unsigned NOT NULL,\r\n\t  `option_id` int(11) NOT NULL default '0',\r\n\t  `default_title` tinyint(1) NOT NULL default '1',\r\n\t  `default_price` tinyint(1) NOT NULL default '1',\r\n\t  `default_image` tinyint(1) NOT NULL default '1',\r\n\t  `default_sort_order` tinyint(1) NOT NULL default '1',\r\n\t  `default_personal_message` tinyint(1) NOT NULL default '1',\r\n\t  `default_status` tinyint(1) NOT NULL default '1',\r\n\t  `default_character` tinyint(1) NOT NULL default '1',\r\n\t  INDEX(`store_id`),\r\n\t  FOREIGN KEY (`store_id`) REFERENCES {$this->getTable('core/store')} (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE, \r\n\t  PRIMARY KEY (`giftwrap_id`)\r\n\t) ENGINE=InnoDB DEFAULT CHARSET=utf8;\r\n\r\n    \r\n\tDROP TABLE IF EXISTS {$this->getTable('giftwrap_selection')};\r\n\tCREATE TABLE {$this->getTable('giftwrap_selection')} (\r\n\t  `id` int(11) unsigned NOT NULL auto_increment,\r\n\t  `quote_id` int(10) unsigned NOT NULL,\r\n\t  `item_id` int(11) NOT NULL,\r\n\t  `style_id` int(11) unsigned NOT NULL,\r\n\t  `message` text NULL,\r\n\t  INDEX(`style_id`),\r\n\t  FOREIGN KEY (`style_id`) REFERENCES `{$this->getTable('giftwrap')}` (`giftwrap_id`) ON DELETE CASCADE ON UPDATE CASCADE,\r\n\t  PRIMARY KEY (`id`)\r\n\t) ENGINE=InnoDB DEFAULT CHARSET=utf8;\r\n");
$installer->endSetup();
开发者ID:AleksNesh,项目名称:pandora,代码行数:19,代码来源:mysql4-install-2.0.3.php

示例11: array

<?php

error_reporting(E_ALL);
require_once 'app/Mage.php';
umask(0);
echo "<pre>";
/* not Mage::run(); */
Mage::app();
$installer = new Mage_Eav_Model_Entity_Setup('core_setup');
$installer->startSetup();
$row = 1;
$fields = array();
if (($handle = fopen("diameter.csv", "r")) !== FALSE) {
    while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
        $fields[] = trim($data[1]);
    }
    fclose($handle);
}
print_r(array_unique($fields));
$color = array_values(array_unique($fields));
//print_r($color);exit;
$iProductEntityTypeId = Mage::getModel('catalog/product')->getResource()->getTypeId();
$aOption = array();
$aOption['attribute_id'] = $installer->getAttributeId($iProductEntityTypeId, 'diameter');
for ($iCount = 0; $iCount < sizeof($color); $iCount++) {
    $aOption['value']['option' . $iCount][0] = $color[$iCount];
}
$installer->addAttributeOption($aOption);
$installer->endSetup();
开发者ID:mSupply,项目名称:runnable_test_repo,代码行数:29,代码来源:diameter.php

示例12: array

$config = array('position' => 1, 'required' => 0, 'label' => 'Comprimento (cm)', 'type' => 'int', 'input' => 'text', 'apply_to' => 'simple,bundle,grouped,configurable', 'note' => 'Comprimento da embalagem do produto (Para cálculo dos Correios)');
$setup->addAttribute('catalog_product', $codigo, $config);
// Add volume to prduct attribute set
$codigo = 'volume_altura';
$config = array('position' => 1, 'required' => 0, 'label' => 'Altura (cm)', 'type' => 'int', 'input' => 'text', 'apply_to' => 'simple,bundle,grouped,configurable', 'note' => 'Altura da embalagem do produto (Para cálculo dos Correios)');
$setup->addAttribute('catalog_product', $codigo, $config);
// Add volume to prduct attribute set
$codigo = 'volume_largura';
$config = array('position' => 1, 'required' => 0, 'label' => 'Largura (cm)', 'type' => 'int', 'input' => 'text', 'apply_to' => 'simple,bundle,grouped,configurable', 'note' => 'Largura da embalagem do produto (Para cálculo dos Correios)');
$setup->addAttribute('catalog_product', $codigo, $config);
$codigo = 'postmethods';
$config = array('position' => 1, 'required' => 0, 'label' => 'Serviços de Entrega', 'type' => 'text', 'input' => 'multiselect', 'source' => 'pedroteixeira_correios/source_postMethods', 'backend' => 'eav/entity_attribute_backend_array', 'apply_to' => 'simple,bundle,grouped,configurable', 'note' => 'Selecione os serviços apropriados para o produto.');
$setup->addAttribute('catalog_product', $codigo, $config);
$codigo = 'fit_size';
$config = array('position' => 1, 'required' => 0, 'label' => 'Diferença do Encaixe (cm)', 'type' => 'varchar', 'input' => 'text', 'apply_to' => 'simple,bundle,grouped,configurable', 'note' => 'Exemplo: Se 1 item mede 10cm de altura, e 2 itens encaixados medem 11cm. A diferença é de 1cm.');
$setup->addAttribute('catalog_product', $codigo, $config);
$codigo = 'posting_days';
$config = array('position' => 1, 'required' => 0, 'label' => 'Prazo de Postagem', 'type' => 'int', 'input' => 'text', 'apply_to' => 'simple,bundle,grouped,configurable', 'note' => 'O prazo total é o Prazo dos Correios acrescido do maior Prazo de Postagem dos produtos no carrinho.');
$setup->addAttribute('catalog_product', $codigo, $config);
// Add Correios Tab
$setIds = $setup->getAllAttributeSetIds('catalog_product');
$attributes = array('volume_comprimento', 'volume_altura', 'volume_largura', 'postmethods', 'fit_size', 'posting_days');
foreach ($setIds as $setId) {
    $setup->addAttributeGroup('catalog_product', $setId, 'Correios', 2);
    $groupId = $setup->getAttributeGroupId('catalog_product', $setId, 'Correios');
    foreach ($attributes as $attribute) {
        $attributeId = $setup->getAttributeId('catalog_product', $attribute);
        $setup->addAttributeToGroup('catalog_product', $setId, $groupId, $attributeId);
    }
}
$installer->endSetup();
开发者ID:rafaelpatro,项目名称:correios,代码行数:31,代码来源:install-4.7.0.php

示例13: explode

<?php

$installer = $this;
$setup = new Mage_Eav_Model_Entity_Setup('catalog_setup');
$installer->startSetup();
$weight = Mage::getModel('catalog/resource_eav_attribute')->load($setup->getAttributeId('catalog_product', 'weight'));
$applyTo = explode(',', $weight->getData('apply_to'));
$applyTo[] = 'giftvoucher';
$weight->addData(array('apply_to' => $applyTo))->save();
$installer->endSetup();
开发者ID:CherylMuniz,项目名称:fashion,代码行数:10,代码来源:mysql4-upgrade-0.1.2-0.2.0.php

示例14: array

 *
 * Do not edit or add to this file if you wish to upgrade this extension to newer
 * version in the future.
 *
 * @category    Magestore
 * @package     Magestore_Customercredit
 * @copyright   Copyright (c) 2012 Magestore (http://www.magestore.com/)
 * @license     http://www.magestore.com/license-agreement.html
 */
/** @var $installer Mage_Core_Model_Resource_Setup */
$installer = $this;
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$installer->startSetup();
//add new attribute - Trung Ha
$setup->addAttribute('catalog_product', 'credit_rate', $arrayName = array('group' => 'Prices', 'type' => 'decimal', 'input' => 'text', 'label' => 'Credit Rate', 'frontend_class' => 'validate-number', 'backend' => '', 'frontend' => '', 'source' => '', 'visible' => 1, 'user_defined' => 1, 'used_for_price_rules' => 1, 'position' => 2, 'unique' => 0, 'default' => '1.0', 'sort_order' => 102, 'note' => 'For e.g: 1.5'));
$creditRate = Mage::getModel('catalog/resource_eav_attribute')->load($setup->getAttributeId('catalog_product', 'credit_rate'));
$creditRate->addData(array('is_global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, 'is_required' => 0, 'apply_to' => array('customercredit'), 'is_configurable' => 1, 'is_searchable' => 1, 'is_visible_in_advanced_search' => 1, 'is_comparable' => 0, 'is_filterable' => 0, 'is_filterable_in_search' => 1, 'is_used_for_promo_rules' => 1, 'is_html_allowed_on_front' => 0, 'is_visible_on_front' => 0, 'used_in_product_listing' => 1, 'used_for_sort_by' => 0, 'backend_type' => 'text'))->save();
$setup->addAttribute('catalog_product', 'credit_value', array('group' => 'Prices', 'type' => 'text', 'input' => 'text', 'frontend_class' => 'disabled', 'label' => 'Credit Value', 'apply_to' => array('customercredit'), 'backend' => '', 'frontend' => '', 'source' => '', 'visible' => 0, 'is_visible_on_front' => 0, 'required' => 0, 'user_defined' => 0, 'is_searchable' => 1, 'is_filterable' => 0, 'is_comparable' => 0, 'position' => 2, 'unique' => 0, 'is_global' => ''));
$attribute = Mage::getSingleton('eav/config')->getAttribute('catalog_product', 'credit_value');
$attribute->save();
//end add new attribute - Trung Ha
//Change label of credit amount - Marko
$attributeId = Mage::getResourceModel('eav/entity_attribute')->getIdByCode('catalog_product', 'credit_amount');
if ($attributeId) {
    $attribute = Mage::getModel('catalog/resource_eav_attribute')->load($attributeId);
    $attribute->setFrontendLabel('Price')->save();
}
//end change label - Marko
//Alter table and add discount field for tables
//sales_flat_order_item
//sales_flat_invoice
开发者ID:protechhelp,项目名称:gamamba,代码行数:31,代码来源:mysql4-upgrade-0.1.0-0.1.1.php

示例15: array

Mage::app()->setCurrentStore(Mage::getModel('core/store')->load(Mage_Core_Model_App::ADMIN_STORE_ID));
$installer = $this;
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$installer->startSetup();
/**
 * Adding a lookup table for Divido
 */
$conn = $installer->getConnection();
$lookup_table = $conn->newTable($installer->getTable('callback/lookup'));
$lookup_table->addColumn('lookup_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array('identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true), 'Id')->addColumn('salt', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255, array('nullable' => false), 'Salt')->addColumn('quote_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array('nullable' => false, 'unsigned' => true), 'Quote ID');
$lookup_table->addIndex($installer->getIdxName('callback/lookup', array('quote_id'), Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE), array('quote_id'), array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE));
$conn->createTable($lookup_table);
/**
 * Adding Divido attributes to products
 */
$groupName = 'Divido';
$entityTypeId = $setup->getEntityTypeId('catalog_product');
$defaultAttrSetId = $setup->getDefaultAttributeSetId($entityTypeId);
// adding attribute group
$setup->addAttributeGroup($entityTypeId, $defaultAttrSetId, $groupName, 1000);
$groupId = $setup->getAttributeGroupId($entityTypeId, $defaultAttrSetId, $groupName);
// Add attributes
$planOptionAttrCode = 'divido_plan_option';
$setup->addAttribute($entityTypeId, $planOptionAttrCode, array('label' => 'Available on finance', 'type' => 'varchar', 'input' => 'select', 'backend' => 'eav/entity_attribute_backend_array', 'frontend' => '', 'source' => 'pay/source_option', 'default' => 'default_plans', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'visible' => true, 'required' => true, 'user_defined' => true, 'searchable' => true, 'filterable' => false, 'comparable' => false, 'visible_on_front' => true, 'unique' => false));
$planOptionAttrId = $setup->getAttributeId($entityTypeId, $planOptionAttrCode);
$setup->addAttributeToGroup($entityTypeId, $defaultAttrSetId, $groupId, $planOptionAttrId, null);
$planSelectionAttrCode = 'divido_plan_selection';
$setup->addAttribute($entityTypeId, $planSelectionAttrCode, array('label' => 'Selected plans', 'type' => 'varchar', 'input' => 'multiselect', 'backend' => 'eav/entity_attribute_backend_array', 'frontend' => '', 'source' => 'pay/source_defaultprodplans', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'visible' => true, 'required' => false, 'user_defined' => true, 'searchable' => true, 'filterable' => false, 'comparable' => false, 'visible_on_front' => true, 'unique' => false));
$planSelectionAttrId = $setup->getAttributeId($entityTypeId, $planSelectionAttrCode);
$setup->addAttributeToGroup($entityTypeId, $defaultAttrSetId, $groupId, $planSelectionAttrId, null);
$installer->endSetup();
开发者ID:DividoFinancialServices,项目名称:divido-magento,代码行数:31,代码来源:mysql4-install-0.1.0.php


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