1

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">
    <soap:Header/>
    <soap:Body>
        <dpap:UpdateCustomer>
            <!--Optional:-->
            <dpap:aRequest>
                <!--Optional:-->
                <dpap:Username>DPAPI</dpap:Username>
                <!--Optional:-->
                <dpap:Password>password00</dpap:Password>
                <!--Optional:-->
                <dpap:CustomerNumber>123</dpap:CustomerNumber>
                <!--Optional:-->
                <dpap:CustomerName>Cust Name</dpap:CustomerName>
                <!--Optional:-->
                <dpap:CustomerAddress1>Cust Addr1</dpap:CustomerAddress1>
                <!--Optional:-->
                <dpap:CustomerAddress2></dpap:CustomerAddress2>
                <!--Optional:-->
                <dpap:CustomerCity>Cust City</dpap:CustomerCity>
                <!--Optional:-->
                <dpap:CustomerState>FL</dpap:CustomerState>
                <!--Optional:-->
                <dpap:CustomerZip>33701</dpap:CustomerZip>
            </dpap:aRequest>
        </dpap:UpdateCustomer>
    </soap:Body>
</soap:Envelope>

My observer method, looks like this:

<?php
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.