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.

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.