Note that there are some explanatory texts on larger screens.

plurals
  1. POMagento 1.7.0.2 Oberserver Module
    primarykey
    data
    text
    <p>I am attempting to create an observer module based on <a href="https://stackoverflow.com/questions/10792117/getting-magento-to-send-email-when-a-payment-is-received/">this answer.</a> The end result is to send an email when a specific product has been purchased and payment has been received. I hope to accomplish this by setting the observer to trigger when an order is completed. Thus far, I'm implemented the observer based on what I'd read in the above link and asked it to email me with the order info. So far it does absolutely nothing. Am I doing something wrong? the only modification I've made to what was provided is as follows:</p> <p>/app/code/local/Electricjesus/Notifyowner/Model/Observer.php</p> <pre><code>&lt;?php class Electricjesus_Notifyowner_Model_Observer { public function notifyOwnerEvent($observer) { // parameters you can get from the $observer parameter: // array(’payment’ ? $this, ‘invoice’ ? $invoice) $payment = $observer-&gt;getPayment(); $invoice = $observer-&gt;getInvoice(); // derivative data $order = $invoice-&gt;getOrder(); // Mage_Sales_Model_Order $email = array( 'to' =&gt; 'me@mydomain.com', 'subject' =&gt; 'Confirmed Purchase', 'message' =&gt; 'Hello World. This is a test. $order = ' . $order, 'headers' =&gt; 'From: My Store' ); mail($email['to'], $email['subject'], $email['subject'], $email['headers']); /* - build data - build email structure - send email via any php mailer method you want */ return $this; // always return $this. } } </code></pre> <p>I've also tried writing the relevant info to a file using <code>file_put_contents('observer_log.txt', '$order = '.$order);</code> to no effect. Any advice at all would be appreciated. I apologize for my noobishness. </p> <p>EDIT: My config.xml [updated] file is as follows: </p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;config&gt; &lt;modules&gt; &lt;Electricjesus_Notifyowner&gt; &lt;version&gt;0.1.0&lt;/version&gt; &lt;/Electricjesus_Notifyowner&gt; &lt;/modules&gt; &lt;global&gt; &lt;models&gt; &lt;notifyowner&gt; &lt;class&gt;Electricjesus_Notifyowner_Model&lt;/class&gt; &lt;/notifyowner&gt; &lt;/models&gt; &lt;events&gt; &lt;sales_order_invoice_pay&gt; &lt;observers&gt; &lt;notifyOwnerEvent&gt; &lt;class&gt;notifyowner/observer&lt;/class&gt; &lt;method&gt;notifyOwnerEvent&lt;/method&gt; &lt;/notifyOwnerEvent&gt; &lt;/observers&gt; &lt;/sales_order_invoice_pay&gt; &lt;/events&gt; &lt;/global&gt; &lt;/config&gt; </code></pre> <p>EDIT 2: I have since modified my config.xml It used to be </p> <pre><code>&lt;events&gt; &lt;sales_order_payment_pay&gt; &lt;observers&gt; </code></pre> <p>I changed the event to what you see above, though all the variables appear empty so I can't see if the order contains the product I care about before sending the email.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload