2013-02-27 100 views
2

我为这些类别创建了一个自定义属性。我认为我启用了“'wysiwyg_enabled'=> true”的WYSIWYG编辑器,但所见即所得并没有显示出来。为自定义类别属性启用wysiwyg编辑器

$installer->addAttribute(Mage_Catalog_Model_Category::ENTITY, 'shortdescription', array(
    'type'    => 'text', 
    'backend'   => '', 
    'frontend'   => '', 
    'label'    => 'Short description', 
    'input'    => 'textarea', 
    'class'    => '', 
    'source'   => '', 
    'global'   => '0', 
    'visible'   => true, 
    'required'   => false, 
    'user_defined'  => true, 
    'default'   => '', 
    'searchable'  => false, 
    'filterable'  => false, 
    'comparable'  => false, 
    'visible_on_front' => true, 
    'used_in_product_listing' => false, 
    'unique'   => false, 
    'wysiwyg_enabled' => true, 
    'apply_to'   => '', 
    'is_configurable' => true 
)); 

任何帮助,将不胜感激。我使用magento 1.6.2。

+0

是否textarea的显示没有所见即所得或没什么g显示出来了吗? – 2013-02-27 14:20:57

+0

textarea显示出来,没有编辑器。 – 2013-02-27 14:50:26

回答

7

尝试(没有所有的附加选项)

<?php 
$this->startSetup(); 
$this->addAttribute('catalog_category', 'custom_attribute', array(
    'group'   => 'General', 
    'input'   => 'textarea', 
    'type'   => 'text', 
    'label'   => 'Custom 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(); 

假设在你的设置$this->startSetup()是的Mage_Catalog_Model_Resource_Eav_Mysql4_Setup

<global> 
    <resources> 
     <add_category_attribute> 
      <setup> 
       <module>...</module> 
       <class>Mage_Catalog_Model_Resource_Eav_Mysql4_Setup</class> 
      </setup> 

瞬间你也可以做

$setup = new Mage_Eav_Model_Entity_Setup('core_setup'); 

$setup->addAttribute('catalog_category' ... 

http://www.atwix.com/magento/add-category-attribute/

+0

谢谢,我会给它一个去看看它是否有效。好像我错过了'is_html_allowed_on_front'。 – 2013-02-27 14:51:17

+0

它适合我。 – jamapag 2013-02-27 16:38:56

+1

附加说明:如果它不适合你,请确保$ this'是'Mage_Catalog_Model_Resource_Setup'的一个实例,而不仅仅是'Mage_Eav_Model_Entity_Setup'。 – 2013-07-17 07:45:25

1

如果您已经从Magento管理创建的属性而不是编码,以下可能会有所帮助:

 Go to admin panel > catalog > manage attributes >
select your attribute(eg. short description) > Attribute Information >
properties > Frontend properties...
Now select 'Yes' from the 'Enable WYSIWYG' dropdown.

+1

它是category属性,您不能使用magento admin编辑或添加类别属性。 – jamapag 2013-02-27 14:04:51

+0

但是,如果他们在未来的版本中实现它,我会很高兴。 – 2013-02-27 14:51:41

0

创建SQL更新

is_wysiwyg_enabled

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

is_html_allowed_on_front

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