sessionmagentosoapsingletonmagento-soap-api

Magento: getSingleton('customer/session') doesn't return information when called via SOAP


I am currently trying to get back customer data after submitting an order and capturing the checkout_submit_all_after event with an Observer. If I make the order via the frontend, Mage::getSingleton('customer/session') and Mage::getSingleton('checkout/session') ran inside the observer give me a wealth of information, however when I make an order via SOAP, these methods returns nothing. I also tried Mage::helper('customer')->getCustomer() but it didn't return anything either.

Is there another way I can obtain the data of the last submitted order? Specifically I need the customer from the session and the last order id ala Mage::getSingleton('checkout/session')->getLastRealOrderId().


Solution

  • Check out this nonsense: the quote->customer_email field is originally populated with the email, then after setting the addresses with the SOAP method 'shoppingCartCustomerAddresses', _prepareGuestQuote from Checkout/Model/Api/Resource/Customer.php OVERWRITES this with "$quote->getBillingAddress()->getEmail()). Which has to be blank! Why? Well check out the wsdl definition of the address object:

             <complexType name="shoppingCartCustomerAddressEntity">
                <all>
                    <element name="mode" type="xsd:string" minOccurs="0"/>
                    <element name="address_id" type="xsd:string" minOccurs="0"/>
                    <element name="firstname" type="xsd:string" minOccurs="0"/>
                    <element name="lastname" type="xsd:string" minOccurs="0"/>
                    <element name="company" type="xsd:string" minOccurs="0"/>
                    <element name="street" type="xsd:string" minOccurs="0"/>
                    <element name="city" type="xsd:string" minOccurs="0"/>
                    <element name="region" type="xsd:string" minOccurs="0"/>
                    <element name="region_id" type="xsd:string" minOccurs="0"/>
                    <element name="postcode" type="xsd:string" minOccurs="0"/>
                    <element name="country_id" type="xsd:string" minOccurs="0"/>
                    <element name="telephone" type="xsd:string" minOccurs="0"/>
                    <element name="fax" type="xsd:string" minOccurs="0"/>
                    <element name="is_default_billing" type="xsd:int" minOccurs="0"/>
                    <element name="is_default_shipping" type="xsd:int" minOccurs="0"/>
                </all>
            </complexType>
    

    Do you see an 'email' field in there? I sure don't! So now I have to override the thing just to make it FUNCTIONAL. Seriously Magento, wtf?