Pergunta

I want to override event for method saveDownloadableOrderItem :

<adminhtml>
   <sales_order_item_save_commit_after>
     <observers>
        <downloadable_observer>
              <class>downloadable/observer</class>
              <method>saveDownloadableOrderItem</method>
          </downloadable_observer>
      </observers>
  </sales_order_item_save_commit_after>
</adminhtml>
Foi útil?

Solução

Option 1
If you want to add some more logic int he method saveDownloadableOrderItem but still be able to call the original method you can do this.
Create a new module and in the config.xml file of it, under the global tag, add this:

<models>
    <downloadable>
        <rewrite>
            <observer>[Namespace]_[Module]_Model_Observer</observer>
        <rewrite>
    </downloadable>
</models>

then create the file [Namespace]/[Module]/Model/Observer.php in your module with this content

public function saveDownloadableOrderItem($observer)
{
    //your code here.
}

Option 2
If you want to completely disable the original method and use your own you can do this:
Create a module and in the config.xml file add this code:

<adminhtml>
    <events>
        <sales_order_item_save_commit_after>
            <observers>
               <downloadable_observer>
                   <class>[yourmodule]/observer</class>
                   <method>yourMethodName</method>
               </downloadable_observer>
            </observers>
         </sales_order_item_save_commit_after>
    </events>
</adminhtml>
Licenciado em: CC-BY-SA com atribuição
Não afiliado a magento.stackexchange
scroll top