I have one problem, my code generates in every type of product my new attribute, why? code for sql-install:

/* @var $installer Mage_Catalog_Model_Resource_Setup */
$installer = $this;

// Add attribute
$allowedProductTypes = array(

$installer->addAttribute(Mage_Catalog_Model_Product::ENTITY, 'terms_of_use', array(
    'group'             => 'General',
    'label'             => 'Terms of use',
    'apply_to'          => implode(',', $allowedProductTypes),
    'type'              => 'text',
    'sort_order'        => 4,
    'input'             => 'textarea',
    'default'           => '',
    'global'            => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
    'user_defined'      => true,
    'visible'           => true,
    'required'          => true,
    'wysiwyg_enabled'   => true,
    'searchable'        => false,
    'filterable'        => false,
    'comparable'        => false,
    'unique'            => false,
    'is_configurable'   => false

i dont understand when i have wrong code for what i need.... how i can create the attribute for a only ONE single type of product in code? thanks

  • You code should work. Could you check the table entry catalog_eav_attribute for your attribute. Specifically the apply_to field. May 19, 2015 at 7:42
  • in column apply_to for table catalog_eav_attribute everything is null!!, and my attribute have been created in table eav_attribute and dont have a option apply_to there May 19, 2015 at 8:11
  • Ok so the apply_to did not take effect. You could try either making a new set-up script to update attribute or remove the entry from core_resource and so the script will re-run May 19, 2015 at 8:12

2 Answers 2


The entry for the apply_to field can be found in the table catalog_eav_attribute. This will be a sting separated by commas.

If this entry is NULL then your script did not run correctly. You could try either making a new set-up script to update attribute or remove the entry from core_resourcetable and so the script will re-run.

  • when i delete from core_resource is allow to rerun script., its ok for this, but how i can insert into table catalog_eav_attribute in sql-install.php? i have searched but not related, thanks May 19, 2015 at 9:03

In my case I forgot to use the correct installer resource. Thats why apply_to and all other attributes of catalog_eav_attribute - table were not correctly set.

$installer = Mage::getResourceModel('catalog/setup','catalog_setup');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.