Add category attribute with WYSIWYG enabled

zitix picture zitix · Mar 7, 2013 · Viewed 11.4k times · Source

I'm following this tutorial: http://www.atwix.com/magento/add-category-attribute/ All is working well, attributes are added to categories, but without the WYSIWYG button below the field. WYSIWYG is enabled in System > Config > Content Management.

$this->startSetup();
$this->addAttribute('catalog_category', 'custom_att', array(
    'group'         => 'General',
    'input'         => 'textarea',
    'type'          => 'text',
    'label'         => 'My attribute',
    'backend'       => '',
    'visible'       => true,
    'required'      => false,
    'wysiwyg_enabled' => true,
    'visible_on_front' => true,
    'is_html_allowed_on_front' => true,
    'global'        => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
));
$this->endSetup();

Whatever I try, WYSIWYG is not enabled for my attributes. Can anyone help? Or maybe there is a workaround for this?

EDIT: I searched other posts but all say that this code should add the WYSIWYG:

'wysiwyg_enabled' => true,

but it doesn't.

Answer

Taras picture Taras · Mar 14, 2013

Tried to accomplish same task today and searching through magento code managed to complete my task with this code:

$productEntityTypeId = $installer->getEntityTypeId('catalog_product');
$installer->addAttribute($productEntityTypeId, 'some_text', array(
    'group'         => 'General',
    'input'         => 'textarea',
    'type'          => 'text',
    'label'         => 'Some Text',
    'backend'       => '',
    'visible'       => true,
    'required'      => false,
    'visible_on_front' => true,
    'global'        => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
));
$installer->updateAttribute($productEntityTypeId, 'some_text', 'is_wysiwyg_enabled', 1);
$installer->updateAttribute($productEntityTypeId, 'some_text', 'is_html_allowed_on_front', 1);