1

I followed this reference Inchoo to add new Wysiwyg attribute to category in Magento 2.2.4. It's working fine. My custom attribute successfully added in the category but it's showing only textarea instead of Wysiwyg editor.

Help would be appreciated!

0

After digging into magento attribute table structure I found that Magento has changed wysiwyg_enabled field to is_wysiwyg_enabled from catalog_eav_attribute table.

So we need to change wysiwyg_enabled to is_wysiwyg_enabled from setup script

$eavSetup->addAttribute(
    \Magento\Catalog\Model\Category::ENTITY,
    'menu_content',
    [
        'type' => 'text',
        'label' => 'Menu Content',
        'input' => 'textarea',
        'required' => false,
        'sort_order' => 4,
        'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
        'is_wysiwyg_enabled' => true,
        'is_html_allowed_on_front' => true,
        'group' => 'General Information',
    ]
);
3
  • Is this working for you ? i got only textarea instead of wysiwyg – Manish Maheshwari Sep 28 '18 at 12:32
  • @ManishMaheshwari Please check your admin configuration Stores->Configuration->General->Content Management->WYSIWYG Options->Enable WYSIWYG Editor Set to "Disabled By Default" or "Enabled By Default". If it is set to "Disabled Completely" you will get only Textarea. – Agnes Mar 13 '19 at 6:31
  • Event WYSIWYG enable in admin but not showing editor. – Anees Apr 9 '20 at 11:07
0
$eavSetup->addAttribute(
    \Magento\Catalog\Model\Product::ENTITY,
        'menu_content',
        [
            'type' => 'text',
            'backend' => '',
            'frontend' => '',
            'label' => 'Menu Content',
            'input' => 'textarea',
            'class' => '',
            'source' => '',
            'backend' => 'Magento\Eav\Model\Entity\Attribute\Backend\ArrayBackend',
            'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_GLOBAL,
            'visible' => true,
            'required' => false,
            'user_defined' => false,
            'default' => 0,
            'searchable' => false,
            'filterable' => true,
            'comparable' => false,
            'visible_on_front' => true,
            'used_in_product_listing' => true,
            'is_wysiwyg_enabled'      => TRUE,
            'unique' => false,
            'apply_to' => ''
        ]
    );

define in XML file app\code\SilkSoftware\ModuleName\view\adminhtml\ui_component\category_form.xml

<?xml version="1.0" encoding="UTF-8"?>
<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
    <fieldset name="general">

        <field name="menu_item">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="class" xsi:type="string">Magento\Catalog\Ui\Component\Category\Form\Element\Wysiwyg</item>
                    <item name="formElement" xsi:type="string">wysiwyg</item>
                    <item name="wysiwygConfigData" xsi:type="array">
                        <item name="settings" xsi:type="array">
                            <item name="theme_advanced_buttons1" xsi:type="string">bold,italic,|,justifyleft,justifycenter,justifyright,|,fontselect,fontsizeselect,|,forecolor,backcolor,|,link,unlink,image,|,bullist,numlist,|,code</item>
                            <item name="theme_advanced_buttons2" xsi:type="boolean">false</item>
                            <item name="theme_advanced_buttons3" xsi:type="boolean">false</item>
                            <item name="theme_advanced_buttons4" xsi:type="boolean">false</item>
                            <item name="theme_advanced_statusbar_location" xsi:type="boolean">false</item>
                        </item>
                        <item name="files_browser_window_url" xsi:type="boolean">false</item>
                        <item name="height" xsi:type="string">100px</item>
                        <item name="toggle_button" xsi:type="boolean">false</item>
                        <item name="add_variables" xsi:type="boolean">false</item>
                        <item name="add_widgets" xsi:type="boolean">false</item>
                        <item name="add_images" xsi:type="boolean">false</item>
                    </item>
                    <item name="template" xsi:type="string">ui/form/field</item>
                    <item name="source" xsi:type="string">category</item>
                    <item name="wysiwyg" xsi:type="boolean">true</item>
                    <item name="dataScope" xsi:type="string">menu_item</item>
                    <item name="sortOrder" xsi:type="number">110</item>
                    <item name="rows" xsi:type="number">8</item>
                    <item name="label" xsi:type="string" translate="true">Menu Item</item>
                    <item name="notice" xsi:type="string" translate="true"></item>
                    <item name="additionalClasses" xsi:type="string"></item>

                </item>
            </argument>
        </field>

    </fieldset>
</form>
0
$eavSetup -> addAttribute(\Magento\Catalog\Model\Category :: ENTITY, 'menu_content', [
                        'type' => 'text',
                        'label' => 'Menu Content',
                        'input' => 'textarea',
                        'required' => false,
                        'sort_order' => 110,
                        'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
                        'is_wysiwyg_enabled' => true,
                        'is_html_allowed_on_front' => false,
                        'group' => 'General Information',
                        "default" => "",
                        "class"    => "",
                        "note"       => ""
            ]
            );

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.