I have a module, which grabs the customer information everytime a customer is updated. Right now, the customer data is stored in the var log file and I want to send this information to a SOAP API, that was created for me through our software.

I have been provided with a URL for our webservice (http://pop.example.com/DPAPIServices/DPAPIServices.asmx)

and then an example of the SOAP message:

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:dpap="http://www.example.com/DPAPIServices">
                <dpap:CustomerName>Cust Name</dpap:CustomerName>
                <dpap:CustomerAddress1>Cust Addr1</dpap:CustomerAddress1>
                <dpap:CustomerCity>Cust City</dpap:CustomerCity>

My observer method, looks like this:

class Mage_Customerupdate_Model_Observer 
    public function logUpdate(Varien_Event_Observer $observer)
        $customer = $observer->getEvent()->getCustomer();
        $name = $customer->getName();
        $customerId = $customer->getId();
        $billingaddress = $customer->getDefaultBillingAddress();
        // just check if there is a billing adress
        if ($billingaddress) {
            $fon = $billingaddress->getTelephone(); 
            $street = $billingaddress->getData('street'); 
            $city = $billingaddress->getCity();
            $region = $billingaddress->getRegion();
            $postcode = $billingaddress->getPostcode();
        Mage::log("{$name} ({$customerId}) ({$fon}) ({$street}) ({$region}) ({$city}) ({$postcode})", null, 'customerupdate.log', true);

I am new to observer events, so maybe this is not how it should be done, but I figured out that I should at least give it a try before coming to you all.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.