Modifying the existing Magento functionalities is often difficult and there’s always a risk of conflicts with the extensions or complications after an update. But it turns out that extending the form by additional functionality doesn’t have to cause any problems.

Let’s assume that we want to add a new function to the static block’s form which, for example, will allow you to duplicate the block. The action will be activated by clicking a button in the block edition form.

Before you start, please get familiar with creating your own extension for Magento.



We want to input an additional button to the static block edition form.

To do so, we will need the Magently_Notify module together with the Observer.
1. Add the Magently_Notify extension to /app/etc/modules/Magently_Notify.xml

<?xml version="1.0"?>
           <depends />

2. Add the information about the model to /app/code/local/Magently/Notify/etc/config.xml

<?xml version="1.0"?>

3. Create the observer’s class in the /app/code/local/Magently/Notify/Model/Observer.php file

class Magently_Notify_Model_Observer {

    * Adds notify button to static block edition form.

    * @event adminhtml_widget_container_html_before
   public function beforeContainerHtml($observer)
      $block = $observer->getBlock();

     if ($block instanceof Mage_Adminhtml_Block_Cms_Block_Edit) {
          $product = Mage::registry('current_product');

          $block->addButton('magently_notify_duplicate', array(
              'label'     => Mage::helper('adminhtml')->__('Duplicate'),
              'onclick'   => 'setLocation(\'' . $block->getUrl('*/magently_notify/duplicate/block_id/' . $block_id) . '\')',
              'class'     => 'duplicate',
           ), -1, 0);

4. Assign the observer’s method to the event


The “Duplicate” button should appear on the static block edit page:


Done! Now you should prepare a controller which would handle the “Duplicate” action, but that’s another story…

Please note that adding a button to the products editing form isn’t as easy as this, because the product form doesn’t inherit from the Mage_Adminhtml_Block_Widget_Form_Container block and doesn’t have the addButton() method.