Public Member Functions | |
items ($filters=null) |
Definition at line 34 of file V2.php.
items | ( | $ | filters = null |
) |
Retrieve list of orders by filters
array | $filters |
Reimplemented from Mage_Sales_Model_Order_Api.
Definition at line 42 of file V2.php.
00043 { 00044 //TODO: add full name logic 00045 $collection = Mage::getResourceModel('sales/order_collection') 00046 ->addAttributeToSelect('*') 00047 ->joinAttribute('billing_firstname', 'order_address/firstname', 'billing_address_id', null, 'left') 00048 ->joinAttribute('billing_lastname', 'order_address/lastname', 'billing_address_id', null, 'left') 00049 ->joinAttribute('shipping_firstname', 'order_address/firstname', 'shipping_address_id', null, 'left') 00050 ->joinAttribute('shipping_lastname', 'order_address/lastname', 'shipping_address_id', null, 'left') 00051 ->addExpressionAttributeToSelect('billing_name', 00052 'CONCAT({{billing_firstname}}, " ", {{billing_lastname}})', 00053 array('billing_firstname', 'billing_lastname')) 00054 ->addExpressionAttributeToSelect('shipping_name', 00055 'CONCAT({{shipping_firstname}}, " ", {{shipping_lastname}})', 00056 array('shipping_firstname', 'shipping_lastname')); 00057 00058 $preparedFilters = array(); 00059 if (isset($filters->filter)) { 00060 foreach ($filters->filter as $_filter) { 00061 $preparedFilters[$_filter->key] = $_filter->value; 00062 } 00063 } 00064 if (isset($filters->complex_filter)) { 00065 foreach ($filters->complex_filter as $_filter) { 00066 $_value = $_filter->value; 00067 $preparedFilters[$_filter->key] = array( 00068 $_value->key => $_value->value 00069 ); 00070 } 00071 } 00072 00073 if (!empty($preparedFilters)) { 00074 try { 00075 foreach ($preparedFilters as $field => $value) { 00076 if (isset($this->_attributesMap['order'][$field])) { 00077 $field = $this->_attributesMap['order'][$field]; 00078 } 00079 00080 $collection->addFieldToFilter($field, $value); 00081 } 00082 } catch (Mage_Core_Exception $e) { 00083 $this->_fault('filters_invalid', $e->getMessage()); 00084 } 00085 } 00086 00087 $result = array(); 00088 00089 foreach ($collection as $order) { 00090 $result[] = $this->_getAttributes($order, 'order'); 00091 } 00092 00093 return $result; 00094 }