Magento Observer not being called on order payment pay
UPDATED 05/08/2011 *
I am new to magento and trying to create an observer that will be triggered upon the payment of an order. For now the observer just sends an email however i will be extending upon this in the future, however i need to get the code working first.
I am using Magento 1.5.1.0 and having looked at the event hooks cheatsheat @ http://www.nicksays.co.uk/magento_events_cheat_sheet/ i can see that the event i want to hook onto is
'sales_order_payment_pay'
that is dispatched from
'app/code/local/Mage/Sales/Model/Order/Payment.php'.
as i have overwitten the file in the core folder
After reading numerous articles i understand i need to create 3 files which are as follows
app/etc/modules/PackageName_ModuleName.xml - > contains the xml file stating where the module can be found
app/code/local/PackageName/ModuleName/etc/config.xml -> which attaches the observer to the dispatched 'sales_order_payment_pay' event
app/code/local/PackageName/ModuleName/Model/Observer.php -> consists of a class which contains a method that is called by config.xml when the 'sales_order_payment_pay event is fired.
Here are the files i have created and the directory's the files live in, the code will be extended to do more than send an email when 'sales_order_payment_pay' is triggered, i am just debugging at the minuite.
My code is as follows, No email is being recived on payment of orders
app/etc/modules/Juno_Sales.xml
<?xml version="1.0"?>
<config>
<modules>
<Juno_Finalise>
<active>true</active>
<codePool>local</codePool>
开发者_如何转开发 </Juno_Finalise>
</modules>
</config>
app/code/local/Juno/Sales/etc/config.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Juno_Sales>
<version>0.1.0</version>
</Juno_Sales>
</modules>
<global>
<models>
<junofinalise>
<class>Juno_Sales_Model</class>
</junofinalise>
</models>
<events>
<sales_order_payment_pay>
<observers>
<juno_sales_order_observer>
<type>singleton</type>
<class>junofinalise/order_observer</class>
<method>finaliseJunoOrder</method>
</juno_sales_order_observer>
</observers>
</sales_order_payment_pay>
</events>
</global>
</config>
app/code/local/Juno/Sales/Model/Order/Observer.php
<?php
Mage::log(__FILE__);
class Juno_Finalise_Model_Order_Observer
{
public function finaliseJunoOrder($event)
{
mail('ian.cassidy1404@gmail.com','call_juno_api','now call juno api');
/*
Sale has now been processed and is paid for, function needs modifying to call juno api
*/
}
}
?>
Any help would be much appreciated.
Many thanks
Ian
Your class Juno_Finalise_Model_Observer
should be Juno_Finalise_Model_Order_Observer
.
精彩评论