2

As per SOAP API need we want's to delimit street into street 1 and street 2 fields for result.

I have override info method of Mage_Sales_Model_Order_Api Class

    public function info($orderIncrementId)
    {

        $result = parent::info($orderIncrementId);
        $order = $this->_initOrder($orderIncrementId);

        $streetLines = $order->getBillingAddress()->getStreet();
       // unset($result['billing_address']['street']);
        foreach ($streetLines as $i=>$line) {
            $result['billing_address']['address_street'.($i+1)] = $line; 
        }  

        $streetLines1 = $order->getShippingAddress()->getStreet();
       // unset($result['shipping_address']['street']);
        foreach ($streetLines1 as $i=>$line) {
            $result['shipping_address']['address_street'.($i+1)] = $line; 
        }

        return $result;
    }

And also added below code in wsdl.xml of custom module in local

<?xml version="1.0" encoding="UTF-8"?>
<definitions>
    <types>
        <schema> 
              <complexType name="salesOrderAddressEntity">
                <all> 
                     <element name="address_street1" type="xsd:string" minOccurs="0" />
                     <element name="address_street2" type="xsd:string" minOccurs="0" />
                </all>
            </complexType>
            </schema>
        </types>
</definitions>

Also below code in wsi.xml in custom module

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:typens="urn:{{var wsdl.name}}"
             xmlns:xsd="http://www.w3.org/2001/XMLSchema"
             xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
             xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
             xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
             name="{{var wsdl.name}}"
             targetNamespace="urn:{{var wsdl.name}}">
        <wsdl:types>
            <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:{{var wsdl.name}}">
                  <xsd:complexType name="salesOrderAddressEntity">
                    <xsd:sequence> 
                          <xsd:element name="address_street1" type="xsd:string" minOccurs="0" />
                      <xsd:element name="address_street2" type="xsd:string" minOccurs="0" />
                    </xsd:sequence>
                </xsd:complexType>
                </xsd:schema>
        </wsdl:types>
 </wsdl:definitions>

Below code in api2.xml:

<?xml version="1.0"?>
<config>
    <api2>  
      <resources>
            <order translate="title" module="api2">
                <attributes   module="api2">
                  <order_type>Order Type</order_type>
                </attributes>
            </order>
             <order_address translate="title" module="api2">
                <attributes translate=" address_street1 address_street2 "   module="api2"> 
                     <address_street1>Street1</address_street1>
                 <address_street2>Street2</address_street2> 
                </attributes> 
             </order_address>
        </resources>
   </api2>
</config>

Is anything else i need to modify to show street as street1 & street2 in result of API method salesOrderInfo?

If I print $result in info(), it is showing street1 & street2 field values in shipping_address and billing_address array, but when I print SOAP API response then it is not displaying it's value.

  • I have also created 2 attributes 'address_street1' and 'address_street2' in customer_address – Bijal Bhavsar Nov 12 '13 at 12:29
1

As per above description suddenly it is working fine. Now it is showing address_street1 & address_street2 in SalesOrderInfo Soap Api method response.

I think it was Caching issue.

  • was there any more to your extension to get this working? I have written up an extension referencing your code above and have successfully rewritten the sales/order_api as well as sales/order_api_v2 models, made sure to include your *.xml files, as well as added street_address1 and street_address_2 attributes to the customer_address entity type and still no luck. Tried blowing out the var/cache directory as well as files within the server's /tmp directory. Magento will still only include the native attributes for the data returned though. – Darren Felton Oct 31 '16 at 22:18
  • Nevermind, it's working! You were indeed correct that it is a caching issue. Just not in the typical location. The server was caching wsdl definitions for sites (shared server) in /tmp. Deleting /tmp/wsdl-{USER}-* fixed the issue. ({USER} being the actual user the site runs as, and * being a long jibberish value. There was only one of these files per site that I found). – Darren Felton Oct 31 '16 at 22:36

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.