I have this code, after trying for hours I still cant figure this out.. Custom API works fine but the observer never fires..
I want to fire this observer after an admin edits/saves a customer through admin panel.
local/ghs/ghsapi/etc/api.xml:
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<ghs_ghsApi>
<version>0.1.0</version>
</ghs_ghsApi>
</modules>
<global>
<models>
<ghs_ghsapi>
<class>ghs_ghsApi_Model</class>
</ghs_ghsapi>
</models>
<events>
<adminhtml_customer_save_after>
<observers>
<fire_delete>
<class>ghs_ghsapi/observer</class>
<method>observeOrders</method>
</fire_delete>
</observers>
</adminhtml_customer_save_after>
</events>
</global>
<api>
<resources>
<ghs translate="title" module="customer">
<model>ghs_ghsApi_Model_Api</model>
<title>Customer Resource</title>
<acl>ghs</acl>
<methods>
<orderlist translate="title" module="customer">
<title>Retrieve customer data</title>
<acl>ghs/orderlist</acl>
<method>orderlist</method>
</orderlist>
<ordertotal translate="title" module="customer">
<title>Retrieve customer data</title>
<acl>ghs/ordertotal</acl>
<method>ordertotal</method>
</ordertotal>
</methods>
<faults module="xyz">
</faults>
</ghs>
</resources>
</api>
</config>
local/ghs/ghsApi/Model/Observer.php:
<?php
class ghs_ghsApi_Model_Observer
{
public function observeOrders($observer)
{
Mage::log('Observer works!');
}
}
Best Answer
aris;
Issue1:
you have not create config.xml code and you have put config code at api.xml that is wrong;
code isIssue2: folder Name is wrong should be
Extension name Space:
Ghs
and Module is :
Ghsapi
That means folder stucure should be
Issue3:api.xml code: