1

I am trying to pull cod_fee column value from sales_flat_invoice or sales_flat_order table from SOAP API.

$proxy = new SoapClient('https://www.mysoresareeudyog.com/api/v2_soap/?wsdl'); // TODO : change url
$sessionId = $proxy->login('api-user', 'api-key'); // TODO : change login and pwd if necessary

$result = $proxy->salesOrderInfo($sessionId, 'ORDL000000012124');
echo "<pre>";
var_dump($result);

However, the above code is not fetching the table column cod_fee. I have gone through many articles. Still I am not able to resolve this. This is the 1st time I am working on API.

Edited

wsdl.xml file (included in -> salesOrderEntity)

<element name="base_cod_fee" type="xsd:string" minOccurs="0" />

wsi.xml file (included in -> salesOrderEntity)

<xsd:element name="base_cod_fee" type="xsd:string" minOccurs="0" />

Api.php file


public function info($orderIncrementId)
{
    $order = $this->_initOrder($orderIncrementId);

    if ($order->getGiftMessageId() > 0) {
        $order->setGiftMessage(
            Mage::getSingleton('giftmessage/message')->load($order->getGiftMessageId())->getMessage()
        );
    }

    $result = $this->_getAttributes($order, 'order');

    $result['shipping_address'] = $this->_getAttributes($order->getShippingAddress(), 'order_address');
    $result['billing_address']  = $this->_getAttributes($order->getBillingAddress(), 'order_address');
    $result['base_cod_fee']  = $this->_getAttributes($order->getBaseCodFee(), 'base_cod_fee');
    $result['items'] = array();

    foreach ($order->getAllItems() as $item) {
        if ($item->getGiftMessageId() > 0) {
            $item->setGiftMessage(
                Mage::getSingleton('giftmessage/message')->load($item->getGiftMessageId())->getMessage()
            );
        }

        $result['items'][] = $this->_getAttributes($item, 'order_item');
    }

    $result['payment'] = $this->_getAttributes($order->getPayment(), 'order_payment');

    $result['status_history'] = array();

    foreach ($order->getAllStatusHistory() as $history) {
        $result['status_history'][] = $this->_getAttributes($history, 'order_status_history');
    }

    return $result;
}
  • by default that field is not there see here – Minesh Patel Apr 15 '16 at 6:33
  • You need to customize api to get that column – Minesh Patel Apr 15 '16 at 6:36
  • @MineshPatel Yes, exactly!! How do I fetch this column? Because this is also a part of the invoice. Till now I have customised the module of the Magento. I don't know how to customise API. Not even basics can you explain me a bit. – Vaibhav Dass Apr 15 '16 at 6:37
  • app/code/core/Mage/Sales/etc/wsdl.xml app/code/core/Mage/Sales/etc/wsi.xml add your column in complexType salesOrderEntity and include in response from file app/code/core/Mage/Sales/Model/Order/Api.php method info() – Minesh Patel Apr 15 '16 at 6:38
  • @MineshPatel I made the changes as you said. Still I am not able to pull cod_fee – Vaibhav Dass Apr 15 '16 at 7:01
1

by default that field is not there see here

You need to customize api to get that column

app/code/core/Mage/Sales/etc/wsdl.xml 

app/code/core/Mage/Sales/etc/wsi.xml 

add your column in complexType salesOrderEntity and include in response from file

app/code/core/Mage/Sales/Model/Order/Api.php method

info()

Disable SOAP WSDL cache. Check here

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.