dongqu3623 2013-09-27 08:07
浏览 4
已采纳

Magento - 创建属性并将其应用于指定的产品类型

I have created an attribute for my extension from this tutorials -

http://www.magentocommerce.com/wiki/5_-_modules_and_development/0_-_module_development_in_magento/installing_custom_attributes_with_your_module

It's the best one I have found on the google.

Acutally I also created a custom type for product, type name is "custom_product", label is "custom product". After I added the attribute, I found it applied to every product type, so how can I just applied it to "custom product" type? So when it only displayed in new "custom product" page?

Thanks.

  • 写回答

1条回答 默认 最新

  • dounaidu0204 2013-09-27 08:11
    关注

    Use this:

    $this->addAttribute('catalog_product', 'custom_product', array(
        'type'                       => 'int',
        'label'                      => 'Custom Product',
        'input'                      => 'select',
        'required'                   => false,
        'user_defined'               => true,
        'searchable'                 => true,
        'filterable'                 => true,
        'comparable'                 => true,
        'visible_in_advanced_search' => true,
        //this is the line that adds it to a type of product
        'apply_to'                   => Mage_Catalog_Model_Product_Type::TYPE_SIMPLE.','.Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE, 
        'group'                      => 'General',
    ));
    

    Check the class Mage_Catalog_Model_Product_Type for all available types and pick yours. You can add as many types as you want separated by comma.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 用matlab 设计一个不动点迭代法求解非线性方程组的代码
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效