|
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());
|