添加属性只是定制产品? [英] Adding attributes to custom product only?

查看:160
本文介绍了添加属性只是定制产品?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

小白在这里。
我曾尝试一些属性添加到我的定制产品(customproduct),但他们最终在所有的产品为好。

我想获得一个属性组/选项卡(自定义设置)只显示下我的定制产品(customproduct)只有常规选项卡。
有人谁能够指引我正确的方式?

我的code如下:(mysql4安装-0.1.0.php)

  $安装= $这一点;
$设置=新Mage_Eav_Model_Entity_Setup('core_setup');
$ installer-> startSetup();
$设置 - >的addAttribute('catalog_product','PARTNERID,阵列(
        '组'=> '自定义设置',
        输入=> '文本',
        '型'=> '文本',
        标签= GT; 合作伙伴ID',
        '后台'= GT; '',
        可见的=> 1,
        必要= GT; 0,
        USER_DEFINED'=> 1,
        '搜索'=> 0,
        '过滤'=> 0,
        '可比'=> 0,
        visible_on_front'=> 0,
        visible_in_advanced_search'=> 0,
        is_html_allowed_on_front'=> 0,
        全球性= GT; Mage_Catalog_Model_Resource_Eav_Attribute :: SCOPE_GLOBAL,
        apply_to'=> customproduct',
    ));


解决方案

要回答我的问题,这里就是答案:
我需要的属性添加到下面的数组,然后重新运行安装InstallScript。
(另外,我在我的我的新产品类型customproduct的配置错误)

  $字段列表=阵列(
            PARTNERID
                        ...
    );    //使这些属性适用于customproduct
    的foreach($字段列表为$场){
        $ applyTo =拆分('',$ installer->的getAttribute('catalog_product',$领域,apply_to'));
        如果(!in_array('customproduct',$ applyTo)){
            $ applyTo [] ='customproduct';
            $ installer-> updateAttribute('catalog_product',$字段,'apply_to',加入(,,$ applyTo));
        }
    }

现在新的属性(S)仅适用于customproduct。

noob here. I have tried to add a few attributes to my custom product (customproduct) but they end up on all products as well.

I would like to get a Group/Tab (Custom Settings) of attributes to show just under the General Tab on my Custom Product (customproduct) only. Someone who can guide me the right way?

My code looks like this: (mysql4-install-0.1.0.php)

$installer = $this;
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$installer->startSetup();
$setup->addAttribute('catalog_product', 'PartnerID', array(
        'group'         => 'Custom Settings',
        'input'         => 'text',
        'type'          => 'text',
        'label'         => 'Partner ID',
        'backend'       => '',
        'visible'       => 1,
        'required'      => 0,
        'user_defined' => 1,
        'searchable' => 0,
        'filterable' => 0,
        'comparable'    => 0,
        'visible_on_front' => 0,
        'visible_in_advanced_search'  => 0,
        'is_html_allowed_on_front' => 0,
        'global'        => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
        'apply_to'      => 'customproduct',
    ));

解决方案

To answer my own question, here is the answer: I needed to add the attributes to the following array and re-run the installscript. (Also, I had an error in my configuration of my new product type customproduct)

$fieldList = array(
            'PartnerId'
                        ...
    );

    // make these attributes applicable to customproduct
    foreach ($fieldList as $field) {
        $applyTo = split(',', $installer->getAttribute('catalog_product', $field, 'apply_to'));
        if (!in_array('customproduct', $applyTo)) {
            $applyTo[] = 'customproduct';
            $installer->updateAttribute('catalog_product', $field, 'apply_to', join(',', $applyTo));
        }
    }

Now the new attribute(s) are only available for customproduct.

这篇关于添加属性只是定制产品?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆