添加启用所见即所得的类别属性



我遵循这个教程:http://www.atwix.com/magento/add-category-attribute/一切正常,属性被添加到类别中,但是字段下面没有WYSIWYG按钮。在"系统>配置>内容管理"中启用所见即所得。

$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();

无论我如何尝试,我的属性都没有启用所见即所得。有人能帮忙吗?或者可能有解决这个问题的方法?

编辑:我搜索了其他帖子,但都说这段代码应该添加所见即所得:
'wysiwyg_enabled' => true,

今天尝试完成相同的任务,并通过magento代码搜索成功完成我的任务,使用以下代码:

$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);

这行得通:

$installer->updateAttribute('catalog_category', 'certifications', 'is_wysiwyg_enabled', 1);
$installer->updateAttribute('catalog_category', 'certifications', 'is_html_allowed_on_front', 1);

这对我有用:

$installer->addAttribute('catalog_category', 'short_description', array(
    'type' => 'varchar',
    'label' => 'Short Description',
    'input' => 'textarea',
    'default' => '',
    'sort_order' => 1,
    'required' => false,
    'wysiwyg_enabled' => true,
    'visible_on_front' => true,
    'is_html_allowed_on_front' => true,
    'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
    'group' => 'General Information',
));

注意以下三个条目:

    'wysiwyg_enabled' => true,
    'visible_on_front' => true,
    'is_html_allowed_on_front' => true,

在magento根目录下创建php文件,粘贴下面的代码并在浏览器中运行:-

ini_set('display_errors',0);
require_once 'app/Mage.php';
Mage::app();
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');

function createNewAttributeSet($name) {
    Mage::app('default');
    $modelSet = Mage::getModel('eav/entity_attribute_set')
    ->setEntityTypeId(4) // 4 == "catalog/product"
    ->setAttributeSetName($name);
    $modelSet->save();
    $modelSet->initFromSkeleton(4)->save(); // same thing
}
// Replace your attribute name with "extra_info"
$setup->addAttribute('catalog_category', 'extra_info', array(
        'group'             => 'General Information',
        'type'              => 'text',
        'backend'           => '',
        'frontend'          => '',
        'label'             => 'Extra Information',
        'wysiwyg_enabled' => true,
        'visible_on_front' => true,
        'is_html_allowed_on_front' => true,
        'input'             => 'textarea',
        'class'             => '',
        'source'            => 'eav/entity_attribute_source_boolean',
        'global'     => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
        'visible'           => 1,
        'required'          => 0,
        'user_defined'      => 0,
        'default'           => '',
        'searchable'        => 0,
        'filterable'        => 0,
        'comparable'        => 0,
        'visible_on_front'  => 0,
        'unique'            => 0,
        'position'          => 1,
));
$setup->updateAttribute('catalog_category', 'extra_info', 'is_wysiwyg_enabled', 1);
$setup->updateAttribute('catalog_category', 'extra_info', 'is_html_allowed_on_front', 1);

最新更新