首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何在magento中为产品属性添加新字段?

如何在magento中为产品属性添加新字段?
EN

Stack Overflow用户
提问于 2014-09-29 14:56:52
回答 1查看 91关注 0票数 0

我想在下订单的时候给制造商发电子邮件。为此,我想在制造商产品属性中添加制造商的电子邮件地址?如何做到这一点?

EN

回答 1

Stack Overflow用户

发布于 2014-09-30 01:15:51

我假设你是在问如何在代码中做到这一点?无论如何,只需构建一个带有安装脚本的小模块(web上的所有教程),并使安装脚本看起来像这样:

代码语言:javascript
运行
复制
$installer = $this;
$installer->startSetup();

// check if the attribute exists
if (Mage::getModel('catalog/resource_eav_attribute')->loadByCode('catalog_product','calculated_sold')->getId() !== NULL) {
    $installer->removeAttribute('catalog_product', 'calculated_sold');
}

// not anymore, that's for sure!
//   Note! For product attributes the XML set class needs to be "Mage_Catalog_Model_Resource_Setup"
//   instead of "Mage_Customer_Model_Entity_Setup" as you would usually go with.
$installer->addAttribute('catalog_product','calculated_sold', array (
    'type'                       => 'decimal',
    'label'                      => 'Calculated sold',
    'input'                      => 'price',          // for filtering to work only certain input types allowed
    'global'                     => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
    'searchable'                 => true,
    'filterable'                 => true,
    'visible'                    => false,
    'required'                   => false,
    'visible_in_advanced_search' => true,
    'used_in_product_listing'    => true,
    'used_for_sort_by'           => true,
    'apply_to'                   => 'configurable',  // yeah!
));

$installer->endSetup();

这个示例添加了一个属性来跟踪售出的商品数量,但它将让您了解如何根据自己的需要进行更改。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26094090

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档