Search code examples
wysiwygmagento

Magento: How to add the widget button to the WYSIWYG Products Editor


I want to allow adding the Catalog Product Link widget in the description field of a product (so I can easily link to other products in the description). I've already extended Mage_Catalog_Model_Product by creating a file like:

class mymodule_Catalog_Model_Product extends Mage_Catalog_Model_Product
{

    /**
      * Add getDescription function that interprets widget or static blocks
      * within product descriptions
      */
    public function getDescription() {
        $processor = Mage::getModel('widget/template_filter');
        $html = $processor->filter($this->getData('description'));
        return $html;
    }

}

Now it works fine if I type something like

{{widget type="catalog/product_widget_link" anchor_text="my text" template="catalog/product/widget/link/link_inline.phtml" id_path="product/1234"}}

into the description field -- it creates a link to the product Id 1234.

But I want to add the actual Catalog Product Link widget button in the WYSIWYG editor for editing a product. The button is already in the CMS editor, but I am missing what I need to modify in order to add this widget to the Admin interface for editing a product. Can someone help me out?


Solution

  • I was able to do this by overriding the core file

    app/code/local/Mage/Adminhtml/Block/Catalog/Helper/Form/Wysiwyg/Content.php
    

    and setting

    $config['add_widgets']           = true;
    

    Now the widget button shows up in all WYSIWIG editors in the admin interface.