I'm having a problem in a Magento Module. I'm trying to modify a module to add an observer that will do stuf only after the invoice is created and the order is paid (sales_order_invoice_save_after), and this is what the config file looks like:

<?xml version="1.0"?>
      <moloni module="moloni">
          <molonibackend module="moloni">
          <title>Allow Everything</title>
            <moloni translate="title" module="moloni">
                  <molonibackend translate="title">

It tries to run the script in the folder includes/src folder, where I have the file Datasource_Moloni_Model_Observer.php .

Inside that file, I have something like this:


class Datasource_Moloni_Model_Auto
public function genInvoice(Varien_Event_Observer $observer)
         echo "inside the function";

echo "outside";

The result no matter what is always "outside". I've tried changing the class so many times in the XML and the PHP files, that I don't know how many things I tried...

Anyone knows why this is happening or has any sugestion? Would love to ear some feedback!

1 Answer 1


Echoing in files to test them is not ideal. Even more in observers as the way they are called is different than anything else.

I would recommend:

  • Enable the logs in the backend
  • Replace your echo with Mage::log("inside the function"); . Also don't add echo outside of a class declaration, it won't help you debug it.
  • Or even better, use xdebug and add a breakpoint inside your function to see if it's called.
  • Also as you said "It tries to run the script in the folder includes/src folder" I would suggest you disable the compiler under System > Tools > Compilation when developping your module. Recompile and reenable once you're finished your development

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.