I install the attribute with the following script:
$installer = $this;
$installer->startSetup();
$installer->removeAttribute('catalog_product', 'customizableonly');
$installer->addAttribute('catalog_product', 'customizableonly', array(
'group' => 'General',
'input' => 'select',
'type' => 'int',
'label' => 'Customizable Only',
'source' => 'eav/entity_attribute_source_boolean',
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
'visible' => 1,
'required' => 0,
'visible_on_front' => 0,
'is_html_allowed_on_front' => 0,
'is_configurable' => 0,
'searchable' => 0,
'filterable' => 0,
'comparable' => 0,
'unique' => false,
'user_defined' => false,
'default' => 0,
'is_user_defined' => false,
'used_in_product_listing' => true
));
$this->endSetup();
Also tried with $installer = new Mage_Catalog_Model_Resource_Eav_Mysql4_Setup('core_setup');
And then I am using the value of the attribute in some other code. But I always get null
. I found out that, the attribute does not get set a default value. When I open a product - the dropdown shows No
, but when I get its value in code it's null
. If I just click the dropdown, simply set No
and save the product - everything works.
How to overcome this?