Public Member Functions | |
__construct () | |
items ($filters=null) | |
info ($orderIncrementId) | |
addComment ($orderIncrementId, $status, $comment=null, $notify=false) | |
hold ($orderIncrementId) | |
unhold ($orderIncrementId) | |
cancel ($orderIncrementId) | |
Protected Member Functions | |
_initOrder ($orderIncrementId) |
Definition at line 34 of file Api.php.
__construct | ( | ) |
_initOrder | ( | $ | orderIncrementId | ) | [protected] |
Initialize basic order model
mixed | $orderIncrementId |
Definition at line 50 of file Api.php.
00051 { 00052 $order = Mage::getModel('sales/order'); 00053 00054 /* @var $order Mage_Sales_Model_Order */ 00055 00056 $order->loadByIncrementId($orderIncrementId); 00057 00058 if (!$order->getId()) { 00059 $this->_fault('not_exists'); 00060 } 00061 00062 return $order; 00063 }
addComment | ( | $ | orderIncrementId, | |
$ | status, | |||
$ | comment = null , |
|||
$ | notify = false | |||
) |
Add comment to order
string | $orderIncrementId | |
string | $status | |
string | $comment | |
boolean | $notify |
Definition at line 151 of file Api.php.
00152 { 00153 $order = $this->_initOrder($orderIncrementId); 00154 00155 $order->addStatusToHistory($status, $comment, $notify); 00156 00157 00158 try { 00159 if ($notify && $comment) { 00160 $oldStore = Mage::getDesign()->getStore(); 00161 $oldArea = Mage::getDesign()->getArea(); 00162 Mage::getDesign()->setStore($order->getStoreId()); 00163 Mage::getDesign()->setArea('frontend'); 00164 } 00165 00166 $order->sendOrderUpdateEmail($notify, $comment); 00167 $order->save(); 00168 if ($notify && $comment) { 00169 Mage::getDesign()->setStore($oldStore); 00170 Mage::getDesign()->setArea($oldArea); 00171 } 00172 00173 } catch (Mage_Core_Exception $e) { 00174 $this->_fault('status_not_changed', $e->getMessage()); 00175 } 00176 00177 return true; 00178 }
cancel | ( | $ | orderIncrementId | ) |
Cancel order
string | $orderIncrementId |
Definition at line 226 of file Api.php.
00227 { 00228 $order = $this->_initOrder($orderIncrementId); 00229 00230 try { 00231 $order->cancel(); 00232 $order->save(); 00233 } catch (Mage_Core_Exception $e) { 00234 $this->_fault('status_not_changed', $e->getMessage()); 00235 } 00236 00237 return true; 00238 }
hold | ( | $ | orderIncrementId | ) |
Hold order
string | $orderIncrementId |
Definition at line 186 of file Api.php.
00187 { 00188 $order = $this->_initOrder($orderIncrementId); 00189 00190 try { 00191 $order->hold(); 00192 $order->save(); 00193 } catch (Mage_Core_Exception $e) { 00194 $this->_fault('status_not_changed', $e->getMessage()); 00195 } 00196 00197 return true; 00198 }
info | ( | $ | orderIncrementId | ) |
Retrieve full order information
string | $orderIncrementId |
Definition at line 117 of file Api.php.
00118 { 00119 $order = $this->_initOrder($orderIncrementId); 00120 00121 $result = $this->_getAttributes($order, 'order'); 00122 00123 $result['shipping_address'] = $this->_getAttributes($order->getShippingAddress(), 'order_address'); 00124 $result['billing_address'] = $this->_getAttributes($order->getBillingAddress(), 'order_address'); 00125 $result['items'] = array(); 00126 00127 foreach ($order->getAllItems() as $item) { 00128 $result['items'][] = $this->_getAttributes($item, 'order_item'); 00129 } 00130 00131 $result['payment'] = $this->_getAttributes($order->getPayment(), 'order_payment'); 00132 00133 $result['status_history'] = array(); 00134 00135 foreach ($order->getAllStatusHistory() as $history) { 00136 $result['status_history'][] = $this->_getAttributes($history, 'order_status_history'); 00137 } 00138 00139 return $result; 00140 }
items | ( | $ | filters = null |
) |
Retrieve list of orders by filters
array | $filters |
Reimplemented in Mage_Sales_Model_Order_Api_V2.
Definition at line 71 of file Api.php.
00072 { 00073 //TODO: add full name logic 00074 $collection = Mage::getResourceModel('sales/order_collection') 00075 ->addAttributeToSelect('*') 00076 ->joinAttribute('billing_firstname', 'order_address/firstname', 'billing_address_id', null, 'left') 00077 ->joinAttribute('billing_lastname', 'order_address/lastname', 'billing_address_id', null, 'left') 00078 ->joinAttribute('shipping_firstname', 'order_address/firstname', 'shipping_address_id', null, 'left') 00079 ->joinAttribute('shipping_lastname', 'order_address/lastname', 'shipping_address_id', null, 'left') 00080 ->addExpressionAttributeToSelect('billing_name', 00081 'CONCAT({{billing_firstname}}, " ", {{billing_lastname}})', 00082 array('billing_firstname', 'billing_lastname')) 00083 ->addExpressionAttributeToSelect('shipping_name', 00084 'CONCAT({{shipping_firstname}}, " ", {{shipping_lastname}})', 00085 array('shipping_firstname', 'shipping_lastname')); 00086 00087 00088 if (is_array($filters)) { 00089 try { 00090 foreach ($filters as $field => $value) { 00091 if (isset($this->_attributesMap['order'][$field])) { 00092 $field = $this->_attributesMap['order'][$field]; 00093 } 00094 00095 $collection->addFieldToFilter($field, $value); 00096 } 00097 } catch (Mage_Core_Exception $e) { 00098 $this->_fault('filters_invalid', $e->getMessage()); 00099 } 00100 } 00101 00102 $result = array(); 00103 00104 foreach ($collection as $order) { 00105 $result[] = $this->_getAttributes($order, 'order'); 00106 } 00107 00108 return $result; 00109 }
unhold | ( | $ | orderIncrementId | ) |
Unhold order
string | $orderIncrementId |
Definition at line 206 of file Api.php.
00207 { 00208 $order = $this->_initOrder($orderIncrementId); 00209 00210 try { 00211 $order->unhold(); 00212 $order->save(); 00213 } catch (Mage_Core_Exception $e) { 00214 $this->_fault('status_not_changed', $e->getMessage()); 00215 } 00216 00217 return true; 00218 }