Search code examples
phpemailmagentoeditorwysiwyg

How to have default data to wysiwyg editor in magento


I need some data added default in the editor. Like I want a template to get loaded in editor when I click on edit template option.. Can anyone suggest me some tip??


Solution

  • Here you can see how it can be done

    $dataa= $this->getTemplate1();

        $fieldset->addField('content', 'editor', array(
            'name' => 'content',
            'label' => Mage::helper('abandonedcart')->__('Content'),
            'title' => Mage::helper('abandonedcart')->__('Content'),
            'style' => 'width:700px; height:500px;',
            'wysiwyg' => true,
            'required' => true,
            'state' => 'html',
            'config' => $wysiwygConfig,
            'value'=> $dataa,
    
        ));
    
        if (Mage::getSingleton('adminhtml/session')->getAbandonedcartData()) {
            $form->addValues(Mage::getSingleton('adminhtml/session')->getAbandonedcartData());
            Mage::getSingleton('adminhtml/session')->setAbandonedcartData(null);
        } elseif (Mage::registry('abandonedcart_data')) {
            $form->addValues(Mage::registry('abandonedcart_data')->getData());
        }
        return parent::_prepareForm();
    }
    

    and calling a function to have data

    public function getTemplate1() {
        $emailTemplate = Mage::getModel('core/email_template')->loadDefault('abandonedcart_abandonedcart_group_email_template');
         $emailTemplate['template_text'];;
           $template_id = Mage::getStoreConfig('abandonedcart/abandonedcart_group/email_template');       
           $emailTemplate = Mage::getModel('core/email_template')->loadDefault($template_id);
    
     return    $processedTemplate = $emailTemplate->getProcessedTemplate();   
    
    
    
    }