Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

SOAP API - sales_order.list (no payment information)
 
safewire
Jr. Member
 
Total Posts:  5
Joined:  2010-04-29
 

I am trying to download the orders using the SOAP API. We are using saved ccs as the payment method for offline processing but the payment object is not returned with the order information in the SOAP response.

I am calling the sales_order.list method and sending the sessionId and a blank filter array to download every order.

Is there something I need to enable or a filter I need to send to download payment information with the order using the API?

 
Magento Community Magento Community
Magento Community
Magento Community
 
safewire
Jr. Member
 
Total Posts:  5
Joined:  2010-04-29
 

Sorry, I see I need to call sales_order.info to retrieve the extra details

 
Magento Community Magento Community
Magento Community
Magento Community
 
sanoju
Jr. Member
 
Total Posts:  30
Joined:  2009-12-15
 

Or you have to customize the API method in Sales/Model/Order/Api.php.

Even in the items method we should be able to get any order data including payment information once we call _initOrder, e.g.,
$order = $this->_initOrder( ... );

The following is our modified version of order API. It doesn’t do what you are looking for, but it might give you some hint.

function items(… $page = 1, $limit = 10)
{
...
if (is_array($filters)) {
try {
foreach ($filters as $field => $value) {
if ($field == ‘store_id’) {
$value = Mage::app()->getStore($value)->getId();
}
...
$collection->setOrder(’created_at’)
->setPageSize(intval($limit))
->setCurPage(intval($page));

foreach ($collection as $order) {
//$result[] = $this->_getAttributes($order, ‘order’);
$r = $this->_getAttributes($order, ‘order’);
$r[’can_edit’] = $order->canEdit();
$r[’can_ship’] = $order->canShip();
$r[’can_invoice’] = $order->canInvoice();
$r[’can_cancel’] = $order->canCancel();
$r[’can_refund’] = $order->canCreditmemo();
$result[] = $r;
}

public function getCount($filters = null) {
$collection = Mage::getResourceModel(’sales/order_collection’);

if (is_array($filters)) {
try {
foreach ($filters as $field => $value) {
if ($field == ‘store_id’) {
$value = Mage::app()->getStore($value)->getId();
}
if (isset($this->_attributesMap[’order’][$field])) {
$field = $this->_attributesMap[’order’][$field];
}

$collection->addFieldToFilter($field, $value);
}
}
catch (Mage_Core_Exception $e) {
$this->_fault(’filters_invalid’, $e->getMessage());
}
}

$result = $collection->getSize();

return $result;
}

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

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

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

foreach ($order->getAllItems() as $item) {
//$result[’items’][] = $this->_getAttributes($item, ‘order_item’);
$product = Mage::getModel(’catalog/product’)->load($item->getProductId());
$orderItem = $this->_getAttributes($item, ‘order_item’);
$orderItem[’custom_products_id’] = $product->getCustomProductsId();
$result[’items’][] = $orderItem;

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

$result[’payment_description’] = $order->getPayment()->getMethodInstance()->setStore($order->getStoreId())->getTitle();
$result[’can_edit’] = $order->canEdit();
$result[’can_ship’] = $order->canShip();
$result[’can_invoice’] = $order->canInvoice();
$result[’can_cancel’] = $order->canCancel();
$result[’can_refund’] = $order->canCreditmemo();

$invoices = $order->getInvoiceCollection()->toArray();
if (count($invoices)> 0) {
$result[’invoice’] = array_pop($invoices);
}

$country = Mage::getModel(’directory/country’)->loadByCode(’JP’);
foreach ($country->getRegions() as $region) {
$region->getName(); $result[’regions’][] = $region->toArray(array(’region_id’, ‘code’, ‘nam
e’));
}
$carriers = array();
$carrierInstances = Mage::getSingleton(’shipping/config’)->getActiveCarriers($order->getStoreId());

foreach ($carrierInstances as $code => $carrier) {
if ($carrier->getConfigData(’title’)) {
$carriers[$code . ‘_’ . $code] = $carrier->getConfigData(’title’);
}
}
$result[’carriers’] = $carriers;

$paymentMethods = array();
$paymentMethodInstances = Mage::helper(’payment’)->getStoreMethods($order->getStoreId());
foreach ($paymentMethodInstances as $methodInstance) {
$paymentMethods[$methodInstance->getCode()] = $methodInstance->getTitle();
}
$result[’payment_methods’] = $paymentMethods;

$result[’statuses’] = $this->getStatuses($order->getStoreId());

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top