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


PHP Mage_Eav_Model_Entity_Setup::getAttributeGroup方法代码示例

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


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

示例1: array

<?php

$installer = $this;
$installer->startSetup();
// 1. Install Catalog Product Attributes
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$entityTypeId = $setup->getEntityTypeId('catalog_product');
$attributeSetId = $setup->getDefaultAttributeSetId($entityTypeId);
if (!$setup->getAttributeGroup($entityTypeId, $attributeSetId, "CandyClub Catalog", "attribute_group_id")) {
    $setup->addAttributeGroup($entityTypeId, $attributeSetId, "CandyClub Catalog", 1);
}
$attributeGroupId = $setup->getAttributeGroup($entityTypeId, $attributeSetId, "CandyClub Catalog", "attribute_group_id");
$installer->removeAttribute('catalog_product', 'most_popular');
$installer->addAttribute('catalog_product', 'most_popular', array('label' => 'Most Popular', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'input' => 'boolean', 'type' => 'int', 'unique' => '0', 'required' => '0', 'used_in_product_listing' => '1', 'visible' => '1', 'user_defined' => '1', 'source' => 'eav/entity_attribute_source_boolean', 'note' => ''));
$installer->addAttributeToSet($entityTypeId, $attributeSetId, $attributeGroupId, 'most_popular');
$installer->removeAttribute('catalog_product', 'best_value');
$installer->addAttribute('catalog_product', 'best_value', array('label' => 'Best Value', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'input' => 'boolean', 'type' => 'int', 'unique' => '0', 'required' => '0', 'used_in_product_listing' => '1', 'visible' => '1', 'user_defined' => '1', 'source' => 'eav/entity_attribute_source_boolean', 'note' => ''));
$installer->addAttributeToSet($entityTypeId, $attributeSetId, $attributeGroupId, 'best_value');
$installer->removeAttribute('catalog_product', 'seal');
$installer->addAttribute('catalog_product', 'seal', array('group' => 'Images', 'label' => 'Seal', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'input' => 'media_image', 'type' => 'varchar', 'unique' => '0', 'required' => '0', 'used_in_product_listing' => '1', 'visible' => '1', 'user_defined' => '1', 'note' => '', 'frontend' => 'catalog/product_attribute_frontend_image'));
//$installer->addAttributeToSet($entityTypeId, $attributeSetId, $attributeGroupId, 'seal');
$installer->removeAttribute('catalog_product', 'subscription_plan');
$installer->addAttribute('catalog_product', 'subscription_plan', array('label' => 'Subscription Plan', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'input' => 'text', 'type' => 'varchar', 'unique' => '0', 'required' => '0', 'used_in_product_listing' => '1', 'visible' => '1', 'user_defined' => '1', 'note' => ''));
$installer->addAttributeToSet($entityTypeId, $attributeSetId, $attributeGroupId, 'subscription_plan');
$installer->removeAttribute('catalog_product', 'retail_value');
$installer->addAttribute('catalog_product', 'retail_value', array('label' => 'Retail Value', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'input' => 'price', 'type' => 'decimal', 'unique' => '0', 'required' => '0', 'used_in_product_listing' => '1', 'visible' => '1', 'user_defined' => '1', 'note' => '', 'backend_model' => 'catalog/product_attribute_backend_price'));
$installer->addAttributeToSet($entityTypeId, $attributeSetId, $attributeGroupId, 'retail_value');
$installer->removeAttribute('catalog_product', 'you_save');
$installer->addAttribute('catalog_product', 'you_save', array('label' => 'You Save', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'input' => 'text', 'type' => 'varchar', 'unique' => '0', 'required' => '0', 'used_in_product_listing' => '1', 'visible' => '1', 'user_defined' => '1', 'note' => ''));
$installer->addAttributeToSet($entityTypeId, $attributeSetId, $attributeGroupId, 'you_save');
$installer->endSetup();
开发者ID:Rodrifer,项目名称:candyclub,代码行数:31,代码来源:mysql4-upgrade-0.1.1-0.1.2.php

示例2: foreach

 * This way they become available for all types of products and can be removed
 * per attribute set by the site administrator for products that does not need
 * them.
 *
 * @var SizeMe_Measurements_Model_Resource_Setup $installer
 */
$installer = $this;
/** @var Mage_Eav_Model_Entity_Setup $setup */
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$installer->startSetup();
$attributesToInstall = $installer->getAttributesToInstall();
/** @var Mage_Eav_Model_Entity_Attribute_Set[] $collection */
$collection = Mage::getResourceModel('eav/entity_attribute_set_collection')->addFieldToFilter('entity_type_id', $setup->getEntityTypeId('catalog_product'));
foreach ($collection as $attributeSet) {
    $attributeSetId = $attributeSet->getId();
    /** @var Mage_Catalog_Model_Product_Attribute_Group $attributeGroup */
    $attributeGroup = $setup->getAttributeGroup('catalog_product', $attributeSetId, SizeMe_Measurements_Helper_Data::ATTRIBUTE_GROUP_NAME);
    if (!$attributeGroup) {
        $setup->addAttributeGroup('catalog_product', $attributeSet->getAttributeSetName(), SizeMe_Measurements_Helper_Data::ATTRIBUTE_GROUP_NAME, 1000);
    }
    $attributes = $installer->getAttributes($attributeSetId);
    $missingAttributeCodes = $installer->getMissingAttributeCodes(array_keys($attributesToInstall), $attributes);
    foreach ($missingAttributeCodes as $code) {
        if (isset($attributesToInstall[$code])) {
            $data = $attributesToInstall[$code];
            $data['attribute_set'] = $attributeSet->getAttributeSetName();
            $setup->addAttribute('catalog_product', $code, $data);
        }
    }
}
$installer->endSetup();
开发者ID:SizeMeCom,项目名称:sizeme-magento-extension,代码行数:31,代码来源:mysql4-install-0.1.0.php

示例3: array

<?php

$installer = $this;
$installer->startSetup();
// 1. Install Catalog Category Attributes
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$setup->removeAttribute('catalog_category', 'display_on_homepage');
$entityTypeId = $setup->getEntityTypeId('catalog_category');
$attributeSetId = $setup->getDefaultAttributeSetId($entityTypeId);
$attributeGroupId = $setup->getAttributeGroup($entityTypeId, $attributeSetId, "General Information");
$setup->addAttribute('catalog_category', 'display_on_homepage', array('group' => "General Information", 'input' => 'select', 'type' => 'int', 'label' => 'Display On Homepage?', 'visible' => 1, 'required' => 0, 'source' => 'eav/entity_attribute_source_boolean', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL));
// 2. Install Catalog Product Attributes
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$entityTypeId = $setup->getEntityTypeId('catalog_product');
$attributeSetId = $setup->getDefaultAttributeSetId($entityTypeId);
if (!$setup->getAttributeGroup($entityTypeId, $attributeSetId, "CandyClub Subscription", "attribute_group_id")) {
    $setup->addAttributeGroup($entityTypeId, $attributeSetId, "CandyClub Subscription", 1);
}
$attributeGroupId = $setup->getAttributeGroup($entityTypeId, $attributeSetId, "CandyClub Subscription", "attribute_group_id");
$installer->removeAttribute('catalog_product', 'is_subscription');
$installer->addAttribute('catalog_product', 'is_subscription', array('label' => 'Is Subscription Product?', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'input' => 'boolean', 'type' => 'int', 'unique' => '0', 'required' => '0', 'used_in_product_listing' => '1', 'visible' => '1', 'user_defined' => '1', 'source' => 'eav/entity_attribute_source_boolean', 'note' => ''));
$installer->addAttributeToSet($entityTypeId, $attributeSetId, $attributeGroupId, 'is_subscription');
$installer->removeAttribute('catalog_product', 'qty_multiplier');
$installer->addAttribute('catalog_product', 'qty_multiplier', array('label' => 'Qty Multiplyer', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'input' => 'text', 'type' => 'int', 'unique' => '0', 'required' => '0', 'used_in_product_listing' => '1', 'visible' => '1', 'user_defined' => '1', 'note' => ''));
$installer->addAttributeToSet($entityTypeId, $attributeSetId, $attributeGroupId, 'qty_multiplier');
// 3. Install Order Item Attributes
$setup = new Mage_Sales_Model_Mysql4_Setup();
$setup->getConnection()->dropColumn($setup->getTable("sales/order_item"), "box_id");
$setup->addAttribute("order_item", "box_id", array('type' => 'int'));
$setup->getConnection()->dropColumn($setup->getTable("sales/quote_item"), "box_id");
$setup->addAttribute("quote_item", "box_id", array('type' => 'int'));
开发者ID:Rodrifer,项目名称:candyclub,代码行数:31,代码来源:mysql4-install-0.1.1.php

示例4: createLightSpeedAttributeSet

 public function createLightSpeedAttributeSet()
 {
     // Find the Default Product attribute set.
     $collection = Mage::getResourceModel('eav/entity_attribute_set_collection')->setEntityTypeFilter($this->getProductEntityTypeId()->getId())->addFieldToFilter('attribute_set_name', 'Default');
     $default_attribute_set = $collection->getFirstItem();
     // Create a attribute set called "LIGHTSPEED_PRODUCT_ATTRIBUTE_SET" based off of the Default product attribute set.
     $lightspeed_attribute_set_name = "LIGHTSPEED_PRODUCT_ATTRIBUTE_SET";
     $attrSet = Mage::getModel('eav/entity_attribute_set');
     $attrSet->setAttributeSetName($lightspeed_attribute_set_name);
     $attrSet->setEntityTypeId($this->getProductEntityTypeId()->getId());
     try {
         $attrSet->save();
     } catch (Mage_Core_Exception $e) {
         $this->_fault('filters_invalid', $e->getMessage());
     }
     $attrSet = $attrSet->initFromSkeleton($default_attribute_set->getId());
     $attrSet->save();
     $setup = new Mage_Eav_Model_Entity_Setup('core_setup');
     // Create a group called LIGHTSPEED_ATTRIBUTES for the
     $setup->addAttributeGroup('catalog_product', $attrSet->getId(), 'LIGHTSPEED_ATTRIBUTES');
     $attrSet->save();
     // Create the attributes to be put into the LIGHTSPEED_ATTRIBUTES group.
     $product_colour_code = 'LIGHTSPEED_PRODUCT_COLOR';
     $product_size_code = 'LIGHTSPEED_PRODUCT_SIZE';
     $this->createAttribute($product_colour_code, 'Color');
     // Colour is spelt Color, the American way.
     $this->createAttribute($product_size_code, 'Size');
     $attribute_group = $setup->getAttributeGroup('catalog_product', $attrSet->getId(), 'LIGHTSPEED_ATTRIBUTES');
     $colour_attribute = $setup->getAttribute('catalog_product', $product_colour_code);
     $size_attribute = $setup->getAttribute('catalog_product', $product_size_code);
     $attrSet->save();
     // Add attributes to attribute set.
     $setup->addAttributeToSet($entityTypeId = 'catalog_product', $attrSet->getId(), $attribute_group['attribute_group_id'], $colour_attribute['attribute_id']);
     $setup->addAttributeToSet($entityTypeId = 'catalog_product', $attrSet->getId(), $attribute_group['attribute_group_id'], $size_attribute['attribute_id']);
     return $attrSet->getId();
 }
开发者ID:macosxvn,项目名称:techheroes,代码行数:36,代码来源:Api.php


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