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.

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

报告相同问题?

悬赏问题

  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?