Setup Script Not Working Properly
Question
I need to add attribute through a setup script.Attribute properties are working,but the frontend properties are not applied as specified in the setup script.For example, visible_on_front
is_html_allowed_on_front
not working.
$installer = $this;
$installer->startSetup();
$entityType = 'catalog_product';
$attributeCode= 'video';
$data = array(
'label' => 'Video',
'input' => 'textarea',
'type' => 'text', //database input type
'visible' => true,
'required' => false,
'comparable'=> false,
'searchable' => false,
'filterable' => false,
'unique' => false,
'visible_on_front' => true,
'is_html_allowed_on_front' => true,
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
'user_defined' => true,
'apply_to' => '',
'is_configurable' => false,
);
$installer->addAttribute($entityType, $attributeCode, $data);
$installer->endSetup();
Part of config.xml
<config>
<modules>
<Company_Video>
<version>0.1.0</version>
</Company_Video>
</modules>
<global>
<resources>
<video_read>
<connection>
<use>core_read</use>
</connection>
</video_read>
<video_write>
<connection>
<use>core_write</use>
</connection>
</video_write>
<video_setup>
<setup>
<module>Company_Video</module>
<class>Mage_Eav_Model_Entity_Setup</class>
</setup>
<connection>
<use>core_setup</use>
</connection>
</video_setup>
</resources>
</global>
</config>
Solution
I think the installer does not run correctly because you are using the wrong setup class.
In your config.xml try placing the following:
<video_setup>
<setup>
<module>Company_Video</module>
<class>Mage_Catalog_Model_Resource_Eav_Mysql4_Setup</class>
</setup>
<connection>
<use>core_setup</use>
</connection>
</video_setup>
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange