1

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>
2

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>
  • Depending on the magento version I recommend to use Mage_Catalog_Model_Resource_Setup – Fabian Blechschmidt Feb 21 '13 at 11:46

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.