Parent Directory
|
Revision Log
|
Revision Graph
|
Patch
| revision 1.1 by mtopolov, Mon May 25 10:30:48 2009 UTC | revision 1.2 by mtopolov, Mon Nov 16 10:38:48 2009 UTC | |
|---|---|---|
| # | Line 5 require_once drupal_get_path('module', ' | Line 5 require_once drupal_get_path('module', ' |
| 5 | require_once drupal_get_path('module', 'magento_api') . '/magento_api.xmlrpc.inc'; | require_once drupal_get_path('module', 'magento_api') . '/magento_api.xmlrpc.inc'; |
| 6 | ||
| 7 | /** | /** |
| 8 | * Implementation of hook_help(). | * Implementation of hook_help(). |
| 9 | */ | */ |
| 10 | function magento_api_help($section) { | function magento_api_help($section) { |
| 11 | switch ($section) { | switch ($section) { |
| 12 | case 'admin/modules#description': | case 'admin/modules#description': |
| # | Line 18 function magento_api_help($section) { | Line 18 function magento_api_help($section) { |
| 18 | * This module provides Magento API. | * This module provides Magento API. |
| 19 | */ | */ |
| 20 | function magento_api_menu() { | function magento_api_menu() { |
| 21 | $items['admin/settings/magento_api'] = array( | $items['admin/settings/magento_api'] = array( |
| 22 | 'title' => 'Magento API Settings', | 'title' => 'Magento API Settings', |
| 23 | 'page callback' => 'drupal_get_form', | 'page callback' => 'drupal_get_form', |
| 24 | 'page arguments' => array('magento_api_settings'), | 'page arguments' => array('magento_api_settings'), |
| 25 | 'access arguments' => array('access administration pages'), | 'access arguments' => array('access administration pages'), |
| 26 | 'type' => MENU_NORMAL_ITEM, | 'type' => MENU_NORMAL_ITEM, |
| 27 | ); | ); |
| 28 | $items['api'] = array( | $items['api'] = array( |
| 29 | 'title' => 'Magento API Test', | 'title' => 'Magento API Test', |
| 30 | 'page callback' => 'drupal_get_form', | 'page callback' => 'drupal_get_form', |
| 31 | 'page arguments' => array('magento_api_test'), | 'page arguments' => array('magento_api_test'), |
| 32 | 'access arguments' => array('access administration pages'), | 'access arguments' => array('access administration pages'), |
| 33 | 'type' => MENU_CALLBACK, | 'type' => MENU_CALLBACK, |
| 34 | ); | ); |
| 35 | $items['admin/settings/magento_synchro'] = array( | $items['admin/settings/magento_synchro'] = array( |
| 36 | 'title' => 'Magento Synchronization Settings', | 'title' => 'Magento Synchronization Settings', |
| 37 | 'page callback' => 'drupal_get_form', | 'page callback' => 'drupal_get_form', |
| 38 | 'page arguments' => array('magento_api_synchro_settings'), | 'page arguments' => array('magento_api_synchro_settings'), |
| 39 | 'access arguments' => array('access administration pages'), | 'access arguments' => array('access administration pages'), |
| 40 | 'type' => MENU_NORMAL_ITEM, | 'type' => MENU_NORMAL_ITEM, |
| 41 | ); | ); |
| 42 | return $items; | return $items; |
| 43 | } | } |
| 44 | ||
| 45 | /** | /** |
| 46 | * Method for testing other API functions (only for debug) | * Method for testing other API functions (only for debug) |
| 47 | */ | */ |
| 48 | function magento_api_test() { | function magento_api_test() { |
| // var_dump(url('/?q=response',array('absolute' => TRUE))); | ||
| // $res = magento_api_catalog_category_tree(); | ||
| // magento_api_synchronize_catalog(); | ||
| // $res = magento_api_catalog_product_attribute_list(9); | ||
| $res = magento_api_catalog_product_list(null, 1); | ||
| // $orderData['magento_user'] = 0; | ||
| // $orderData['products'][] = array('id'=>166, 'qty'=>1); | ||
| //// | ||
| // $res = magento_api_quote_create($orderData); | ||
| // $res = magento_api_catalog_product_full_info(166, 0); | ||
| //152 | ||
| // $res = magento_api_config_websites(); | ||
| // $res = magento_api_config_stores(); | ||
| // $res = magento_api_config_store_views(); | ||
| var_dump($res[119]); | ||
| // die; | ||
| // $tax_tree = taxonomy_get_tree(1); | ||
| // foreach ($tax_tree as $term) { | ||
| // $cid = magento_api_get_catalog_id_by_taxonomy_term($term->tid); | ||
| // var_dump($cid); | ||
| // } | ||
| // $res = taxonomy_get_tree(1); | ||
| // die; | ||
| 49 | } | } |
| 50 | ||
| 51 | /** | /** |
| # | Line 82 function magento_api_test() { | Line 54 function magento_api_test() { |
| 54 | * @return mixed | * @return mixed |
| 55 | */ | */ |
| 56 | function magento_api_settings() { | function magento_api_settings() { |
| 57 | $form = array(); | $form = array(); |
| 58 | ||
| 59 | $form['magento_api_magento_host_url'] = array( | $form['magento_api_magento_host_url'] = array( |
| 60 | '#type' => 'textfield', | '#type' => 'textfield', |
| 61 | '#title' => 'Magento host URL', | '#title' => 'Magento host URL', |
| 62 | '#description' => t('Enter host for XML-RPC connection'), | '#description' => t('Enter host for XML-RPC connection'), |
| 63 | '#default_value' => variable_get('magento_api_magento_host_url', 'http://magentohost/api/xmlrpc/'), | '#default_value' => variable_get('magento_api_magento_host_url', 'http://magentohost/api/xmlrpc/'), |
| 64 | ); | ); |
| 65 | ||
| 66 | $form['magento_api_user'] = array( | $form['magento_api_user'] = array( |
| 67 | '#type' => 'textfield', | '#type' => 'textfield', |
| 68 | '#title' => 'API user', | '#title' => 'API user', |
| 69 | '#description' => t('Enter username for XML-RPC connection'), | '#description' => t('Enter username for XML-RPC connection'), |
| 70 | '#default_value' => variable_get('magento_api_user', ''), | '#default_value' => variable_get('magento_api_user', ''), |
| 71 | ); | ); |
| 72 | ||
| 73 | $form['magento_api_key'] = array( | $form['magento_api_key'] = array( |
| 74 | '#type' => 'password', | '#type' => 'password', |
| 75 | '#title' => 'API key (password)', | '#title' => 'API key (password)', |
| 76 | '#description' => t('Enter password for XML-RPC connection'), | '#description' => t('Enter password for XML-RPC connection'), |
| 77 | '#default_value' => variable_get('magento_api_key', ''), | '#default_value' => variable_get('magento_api_key', ''), |
| 78 | ); | ); |
| 79 | return system_settings_form($form); | return system_settings_form($form); |
| 80 | } | } |
| 81 | /** | /** |
| 82 | * Provide admin settings for synchronization | * Provide admin settings for synchronization |
| # | Line 112 return system_settings_form($form); | Line 84 return system_settings_form($form); |
| 84 | * @return mixed | * @return mixed |
| 85 | */ | */ |
| 86 | function magento_api_synchro_settings() { | function magento_api_synchro_settings() { |
| 87 | $form = array(); | $form = array(); |
| 88 | ||
| 89 | $form['magento_api_log'] = array( | $form['magento_api_log'] = array( |
| 90 | '#type' => 'checkbox', | '#type' => 'checkbox', |
| 91 | '#title' => 'Log synchronisation actions', | '#title' => 'Log synchronisation actions', |
| 92 | '#default_value' => variable_get('magento_api_log', 0), | '#default_value' => variable_get('magento_api_log', 0), |
| 93 | ); | ); |
| 94 | ||
| 95 | $form['magento_synchronize'] = array( | $form['magento_synchronize'] = array( |
| 96 | '#type' => 'fieldset', | '#type' => 'fieldset', |
| 97 | '#title' => t('Manual Synchronization with Magento.'), | '#title' => t('Manual Synchronization with Magento.'), |
| 98 | '#collapsible' => FALSE, | '#collapsible' => FALSE, |
| 99 | ); | ); |
| 100 | $form['magento_synchronize']['synchronize_catalog'] = array( | $form['magento_synchronize']['synchronize_catalog'] = array( |
| 101 | '#type' => 'submit', | '#type' => 'submit', |
| 102 | '#value' => 'Synchronize Catalog into taxonomy', | '#value' => 'Synchronize Catalog into taxonomy', |
| 103 | '#submit' => array('magento_api_synchronize_catalog'), | '#submit' => array('magento_api_synchronize_catalog'), |
| 104 | ); | ); |
| 105 | ||
| 106 | $form['magento_autosynchronize'] = array( | $form['magento_autosynchronize'] = array( |
| 107 | '#type' => 'fieldset', | '#type' => 'fieldset', |
| 108 | '#title' => t('Automatic Synchronization with Magento.'), | '#title' => t('Automatic Synchronization with Magento.'), |
| 109 | '#collapsible' => FALSE, | '#collapsible' => FALSE, |
| 110 | ); | ); |
| 111 | $form['magento_autosynchronize']['magento_products_cron'] = array( | $form['magento_autosynchronize']['magento_products_cron'] = array( |
| 112 | '#type' => 'textfield', | '#type' => 'textfield', |
| 113 | '#title' => t('Time to run Products synchronization'), | '#title' => t('Time to run Products synchronization'), |
| 114 | '#description' => t('In minutes, must be multiple of 15 for default Drupal cron'), | '#description' => t('In minutes, must be multiple of 15 for default Drupal cron'), |
| 115 | '#default_value' => variable_get('magento_products_cron', 1440), // 1 day for default | '#default_value' => variable_get('magento_products_cron', 1440), // 1 day for default |
| 116 | '#element_validate' => array('magento_api_cron_time_validate'), | '#element_validate' => array('magento_api_cron_time_validate'), |
| 117 | ); | ); |
| 118 | $form['magento_autosynchronize']['magento_rules_cron'] = array( | $form['magento_autosynchronize']['magento_rules_cron'] = array( |
| 119 | '#type' => 'textfield', | '#type' => 'textfield', |
| 120 | '#title' => t('Time to run Rules synchronization'), | '#title' => t('Time to run Rules synchronization'), |
| 121 | '#description' => t('In minutes, must be multiple of 15 for default Drupal cron'), | '#description' => t('In minutes, must be multiple of 15 for default Drupal cron'), |
| 122 | '#default_value' => variable_get('magento_rules_cron', 60), // 1 hour for default | '#default_value' => variable_get('magento_rules_cron', 60), // 1 hour for default |
| 123 | '#element_validate' => array('magento_api_cron_time_validate'), | '#element_validate' => array('magento_api_cron_time_validate'), |
| 124 | ); | ); |
| 125 | $form['magento_autosynchronize']['magento_catalog_cron'] = array( | $form['magento_autosynchronize']['magento_catalog_cron'] = array( |
| 126 | '#type' => 'textfield', | '#type' => 'textfield', |
| 127 | '#title' => t('Time to run Catalog synchronization'), | '#title' => t('Time to run Catalog synchronization'), |
| 128 | '#description' => t('In minutes, must be multiple of 15 for default Drupal cron'), | '#description' => t('In minutes, must be multiple of 15 for default Drupal cron'), |
| 129 | '#default_value' => variable_get('magento_catalog_cron', 60), // 1 hour for default | '#default_value' => variable_get('magento_catalog_cron', 60), // 1 hour for default |
| 130 | '#element_validate' => array('magento_api_cron_time_validate'), | '#element_validate' => array('magento_api_cron_time_validate'), |
| 131 | ); | ); |
| 132 | $form['magento_autosynchronize']['magento_stores_cron'] = array( | $form['magento_autosynchronize']['magento_stores_cron'] = array( |
| 133 | '#type' => 'textfield', | '#type' => 'textfield', |
| 134 | '#title' => t('Time to run Websites, Stores and StoreViews synchronization'), | '#title' => t('Time to run Websites, Stores and StoreViews synchronization'), |
| 135 | '#description' => t('In minutes, must be multiple of 15 for default Drupal cron'), | '#description' => t('In minutes, must be multiple of 15 for default Drupal cron'), |
| 136 | '#default_value' => variable_get('magento_stores_cron', 1440), // 1 day for default | '#default_value' => variable_get('magento_stores_cron', 1440), // 1 day for default |
| 137 | '#element_validate' => array('magento_api_cron_time_validate'), | '#element_validate' => array('magento_api_cron_time_validate'), |
| 138 | ); | ); |
| 139 | $form['offer_valid'] = array( | |
| 140 | return system_settings_form($form); | '#type' => 'fieldset', |
| 141 | '#title' => t('Offer Valid date checking settings.'), | |
| 142 | '#collapsible' => FALSE, | |
| 143 | ); | |
| 144 | $form['offer_valid']['magento_products_offer_valid_checking_cron'] = array( | |
| 145 | '#type' => 'textfield', | |
| 146 | '#title' => t('Time to run Offer Valid date checking'), | |
| 147 | '#description' => t('In minutes, must be multiple of 15 for default Drupal cron'), | |
| 148 | '#default_value' => variable_get('magento_products_offer_valid_checking_time', 1440), | |
| 149 | '#element_validate' => array('magento_products_cache_time_validate'), | |
| 150 | ); | |
| 151 | return system_settings_form($form); | |
| 152 | } | } |
| 153 | /* | /* |
| 154 | * Validate time that was entered on settings page | * Validate time that was entered on settings page |
| 155 | */ | */ |
| 156 | function magento_api_cron_time_validate($element, &$form_state) { | function magento_api_cron_time_validate($element, &$form_state) { |
| 157 | if (is_numeric($element['#value']) ) { | if (is_numeric($element['#value']) ) { |
| 158 | if ($element['#value'] <= 0) { | if ($element['#value'] <= 0) { |
| 159 | form_error($element, t('This field must be positive.')); | form_error($element, t('This field must be positive.')); |
| 160 | } | } |
| 161 | }else form_error($element, t('This field must be numeric.')); | }else form_error($element, t('This field must be numeric.')); |
| 162 | } | } |
| 163 | /** | /** |
| 164 | * Create new customer | * Create new customer |
| # | Line 184 if (is_numeric($element['#value']) ) { | Line 167 if (is_numeric($element['#value']) ) { |
| 167 | * @return int | * @return int |
| 168 | */ | */ |
| 169 | function magento_api_customer_create($customerData) { | function magento_api_customer_create($customerData) { |
| 170 | if ($session = _magento_api_get_session()) { | if ($session = _magento_api_get_session()) { |
| 171 | $new_customer = xmlrpc(_magento_api_get_host(), 'call', $session, 'customer.create', array($customerData)); | $new_customer = xmlrpc(_magento_api_get_host(), 'call', $session, 'customer.create', array($customerData)); |
| 172 | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Arguments = %args, Response = %response', array('%drupal_function' => 'magento_api_customer_create', '%magento_function' => 'customer.create', '%args' => serialize(array($customerData)), '%response' => serialize($new_customer)), WATCHDOG_NOTICE, $link = NULL); | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Arguments = %args, Response = %response', array('%drupal_function' => 'magento_api_customer_create', '%magento_function' => 'customer.create', '%args' => serialize(array($customerData)), '%response' => serialize($new_customer)), WATCHDOG_NOTICE, $link = NULL); |
| 173 | if (_magento_api_check_no_errors()) return $new_customer; | if (_magento_api_check_no_errors()) return $new_customer; |
| 174 | else { | else { |
| 175 | if (_magento_api_check_session_expire_error()) { | if (_magento_api_check_session_expire_error()) { |
| 176 | _magento_api_clear_session(); | _magento_api_clear_session(); |
| 177 | return magento_api_customer_create($customerData); | return magento_api_customer_create($customerData); |
| 178 | } | } |
| 179 | else return false; | else return false; |
| 180 | } | } |
| 181 | } | } |
| 182 | return false; | return false; |
| 183 | } | } |
| 184 | ||
| 185 | /** | /** |
| # | Line 208 function magento_api_customer_create($cu | Line 191 function magento_api_customer_create($cu |
| 191 | * @return array | * @return array |
| 192 | */ | */ |
| 193 | function magento_api_customer_info($customerId, $attributes = NULL) { | function magento_api_customer_info($customerId, $attributes = NULL) { |
| 194 | if ($session = _magento_api_get_session()) { | if ($session = _magento_api_get_session()) { |
| 195 | $data = array(); | $data = array(); |
| 196 | $data[] = $customerId; | $data[] = $customerId; |
| 197 | if ($attributes) $data[] = $attributes; | if ($attributes) $data[] = $attributes; |
| 198 | $customer = xmlrpc(_magento_api_get_host(), 'call', $session, 'customer.info', $data); | $customer = xmlrpc(_magento_api_get_host(), 'call', $session, 'customer.info', $data); |
| 199 | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Arguments = %args, Response = %response', array('%drupal_function' => 'magento_api_customer_info', '%magento_function' => 'customer.info', '%args' => serialize(array($customerId, $attributes)), '%response' => serialize($customer)), WATCHDOG_NOTICE, $link = NULL); | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Arguments = %args, Response = %response', array('%drupal_function' => 'magento_api_customer_info', '%magento_function' => 'customer.info', '%args' => serialize(array($customerId, $attributes)), '%response' => serialize($customer)), WATCHDOG_NOTICE, $link = NULL); |
| 200 | if (_magento_api_check_no_errors()) return $customer; | if (_magento_api_check_no_errors()) return $customer; |
| 201 | else { | else { |
| 202 | if (_magento_api_check_session_expire_error()) { | if (_magento_api_check_session_expire_error()) { |
| 203 | _magento_api_clear_session(); | _magento_api_clear_session(); |
| 204 | return magento_api_customer_info($customerId, $attributes); | return magento_api_customer_info($customerId, $attributes); |
| 205 | } | } |
| 206 | else return false; | else return false; |
| 207 | } | } |
| 208 | } | } |
| 209 | return false; | return false; |
| 210 | } | } |
| 211 | ||
| 212 | /** | /** |
| # | Line 234 function magento_api_customer_info($cust | Line 217 function magento_api_customer_info($cust |
| 217 | * @return boolean | * @return boolean |
| 218 | */ | */ |
| 219 | function magento_api_customer_update($customerId, $customerData) { | function magento_api_customer_update($customerId, $customerData) { |
| 220 | if ($session = _magento_api_get_session()) { | if ($session = _magento_api_get_session()) { |
| 221 | $updated = xmlrpc(_magento_api_get_host(), 'call', $session, 'customer.update', array($customerId, $customerData)); | $updated = xmlrpc(_magento_api_get_host(), 'call', $session, 'customer.update', array($customerId, $customerData)); |
| 222 | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Arguments = %args, Response = %response', array('%drupal_function' => 'magento_api_customer_update', '%magento_function' => 'customer.update', '%args' => serialize(array($customerId, $customerData)), '%response' => serialize($updated)), WATCHDOG_NOTICE, $link = NULL); | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Arguments = %args, Response = %response', array('%drupal_function' => 'magento_api_customer_update', '%magento_function' => 'customer.update', '%args' => serialize(array($customerId, $customerData)), '%response' => serialize($updated)), WATCHDOG_NOTICE, $link = NULL); |
| 223 | if (_magento_api_check_no_errors()) return $updated; | if (_magento_api_check_no_errors()) return $updated; |
| 224 | else { | else { |
| 225 | if (_magento_api_check_session_expire_error()) { | if (_magento_api_check_session_expire_error()) { |
| 226 | _magento_api_clear_session(); | _magento_api_clear_session(); |
| 227 | return magento_api_customer_update($customerId, $customerData); | return magento_api_customer_update($customerId, $customerData); |
| 228 | } | } |
| 229 | else return false; | else return false; |
| 230 | } | } |
| 231 | } | } |
| 232 | return false; | return false; |
| 233 | } | } |
| 234 | ||
| 235 | /** | /** |
| # | Line 256 function magento_api_customer_update($cu | Line 239 function magento_api_customer_update($cu |
| 239 | * @return boolean | * @return boolean |
| 240 | */ | */ |
| 241 | function magento_api_customer_delete($customerId) { | function magento_api_customer_delete($customerId) { |
| 242 | if ($session = _magento_api_get_session()) { | if ($session = _magento_api_get_session()) { |
| 243 | $deleted = xmlrpc(_magento_api_get_host(), 'call', $session, 'customer.delete', array($customerId)); | $deleted = xmlrpc(_magento_api_get_host(), 'call', $session, 'customer.delete', array($customerId)); |
| 244 | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Arguments = %args, Response = %response', array('%drupal_function' => 'magento_api_customer_delete', '%magento_function' => 'customer.delete', '%args' => serialize(array($customerId)), '%response' => serialize($deleted)), WATCHDOG_NOTICE, $link = NULL); | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Arguments = %args, Response = %response', array('%drupal_function' => 'magento_api_customer_delete', '%magento_function' => 'customer.delete', '%args' => serialize(array($customerId)), '%response' => serialize($deleted)), WATCHDOG_NOTICE, $link = NULL); |
| 245 | if (_magento_api_check_no_errors()) return $deleted; | if (_magento_api_check_no_errors()) return $deleted; |
| 246 | else { | else { |
| 247 | if (_magento_api_check_session_expire_error()) { | if (_magento_api_check_session_expire_error()) { |
| 248 | _magento_api_clear_session(); | _magento_api_clear_session(); |
| 249 | return magento_api_customer_delete($customerId); | return magento_api_customer_delete($customerId); |
| 250 | } | } |
| 251 | else return false; | else return false; |
| 252 | } | } |
| 253 | } | } |
| 254 | return false; | return false; |
| 255 | } | } |
| 256 | ||
| 257 | /** | /** |
| # | Line 277 function magento_api_customer_delete($cu | Line 260 function magento_api_customer_delete($cu |
| 260 | * @return array | * @return array |
| 261 | */ | */ |
| 262 | function magento_api_customer_group_list() { | function magento_api_customer_group_list() { |
| 263 | if ($session = _magento_api_get_session()) { | if ($session = _magento_api_get_session()) { |
| 264 | $customer_groups = xmlrpc(_magento_api_get_host(), 'call', $session, 'customer_group.list'); | $customer_groups = xmlrpc(_magento_api_get_host(), 'call', $session, 'customer_group.list'); |
| 265 | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Arguments = %args, Response = %response', array('%drupal_function' => 'magento_api_customer_group_list', '%magento_function' => 'customer_group.list', '%args' => serialize(0), '%response' => serialize($customer_groups)), WATCHDOG_NOTICE, $link = NULL); | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Arguments = %args, Response = %response', array('%drupal_function' => 'magento_api_customer_group_list', '%magento_function' => 'customer_group.list', '%args' => serialize(0), '%response' => serialize($customer_groups)), WATCHDOG_NOTICE, $link = NULL); |
| 266 | if (_magento_api_check_no_errors()) { | if (_magento_api_check_no_errors()) { |
| 267 | $result = array(); | $result = array(); |
| 268 | foreach ($customer_groups as $group) { | foreach ($customer_groups as $group) { |
| 269 | $result[$group['customer_group_id']] = $group['customer_group_code']; | $result[$group['customer_group_id']] = $group['customer_group_code']; |
| 270 | } | } |
| 271 | return $result; | return $result; |
| 272 | } | } |
| 273 | else { | else { |
| 274 | if (_magento_api_check_session_expire_error()) { | if (_magento_api_check_session_expire_error()) { |
| 275 | _magento_api_clear_session(); | _magento_api_clear_session(); |
| 276 | return magento_api_customer_group_list(); | return magento_api_customer_group_list(); |
| 277 | } | } |
| 278 | else return false; | else return false; |
| 279 | } | } |
| 280 | } | } |
| 281 | return false; | return false; |
| 282 | } | |
| 283 | ||
| 284 | /** | |
| 285 | * Retrieve customer address list | |
| 286 | * | |
| 287 | * @param string $mail | |
| 288 | * @return array | |
| 289 | */ | |
| 290 | function magento_api_customer_get_customer_address_list($customerId) { | |
| 291 | if ($session = _magento_api_get_session()) { | |
| 292 | $customer_list = xmlrpc(_magento_api_get_host(), 'call', $session, 'customer_address.list', array($customerId)); | |
| 293 | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Arguments = %args, Response = %response', array('%drupal_function' => 'magento_api_customer_get_customer_address_list', '%magento_function' => 'customer_address.list', '%args' => serialize(array($customerId)), '%response' => serialize($customer_list)), WATCHDOG_NOTICE, $link = NULL); | |
| 294 | if (_magento_api_check_no_errors()) return $customer_list; | |
| 295 | else { | |
| 296 | if (_magento_api_check_session_expire_error()) { | |
| 297 | _magento_api_clear_session(); | |
| 298 | return magento_api_customer_get_customer_address_list($customerId); | |
| 299 | } | |
| 300 | else return false; | |
| 301 | } | |
| 302 | } | |
| 303 | return false; | |
| 304 | } | |
| 305 | ||
| 306 | /** | |
| 307 | * Create new customer address | |
| 308 | * | |
| 309 | * @param int $customerId | |
| 310 | * @param array $customerAddress | |
| 311 | * @return mixed | |
| 312 | */ | |
| 313 | function magento_api_customer_customer_address_create($customerId, $customerAddress) { | |
| 314 | if ($session = _magento_api_get_session()) { | |
| 315 | $newAddressId = xmlrpc(_magento_api_get_host(), 'call', $session, 'customer_address.create', array($customerId, $customerAddress)); | |
| 316 | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Arguments = %args, Response = %response', array('%drupal_function' => 'magento_api_customer_customer_address_create', '%magento_function' => 'customer_address.create', '%args' => serialize(array('customerId' => $customerId, 'customerAddress' => $customerAddress)), '%response' => serialize($newAddressId)), WATCHDOG_NOTICE, $link = NULL); | |
| 317 | if (_magento_api_check_no_errors()) return $newAddressId; | |
| 318 | else { | |
| 319 | if (_magento_api_check_session_expire_error()) { | |
| 320 | _magento_api_clear_session(); | |
| 321 | return magento_api_customer_customer_address_create($customerId, $customerAddress); | |
| 322 | } | |
| 323 | else return false; | |
| 324 | } | |
| 325 | } | |
| 326 | return false; | |
| 327 | } | } |
| 328 | ||
| 329 | /** | /** |
| # | Line 305 function magento_api_customer_group_list | Line 333 function magento_api_customer_group_list |
| 333 | * @return array | * @return array |
| 334 | */ | */ |
| 335 | function magento_api_customer_get_customer_id_by_email($mail) { | function magento_api_customer_get_customer_id_by_email($mail) { |
| 336 | if ($session = _magento_api_get_session()) { | $website = magento_stores_get_default_website(); |
| 337 | $customer_list = xmlrpc(_magento_api_get_host(), 'call', $session, 'customer.list', array($mail)); | if ($session = _magento_api_get_session()) { |
| 338 | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Arguments = %args, Response = %response', array('%drupal_function' => 'magento_api_customer_get_customer_id_by_email', '%magento_function' => 'customer.list', '%args' => serialize(array($mail)), '%response' => serialize($customer_list)), WATCHDOG_NOTICE, $link = NULL); | $customer_list = xmlrpc(_magento_api_get_host(), 'call', $session, 'customer.list', array(array('email' => $mail, 'website_id' => $website), 'email')); |
| 339 | if (_magento_api_check_no_errors()) return $customer_list[0]['customer_id']; | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Arguments = %args, Response = %response', array('%drupal_function' => 'magento_api_customer_get_customer_id_by_email', '%magento_function' => 'customer.list', '%args' => serialize(array($mail)), '%response' => serialize($customer_list)), WATCHDOG_NOTICE, $link = NULL); |
| 340 | else { | if (_magento_api_check_no_errors()) return $customer_list[0]['customer_id']; |
| 341 | if (_magento_api_check_session_expire_error()) { | else { |
| 342 | _magento_api_clear_session(); | if (_magento_api_check_session_expire_error()) { |
| 343 | return magento_api_customer_get_customer_id_by_email($mail); | _magento_api_clear_session(); |
| 344 | } | return magento_api_customer_get_customer_id_by_email($mail); |
| 345 | else return false; | } |
| 346 | } | else return false; |
| 347 | } | } |
| 348 | return false; | } |
| 349 | return false; | |
| 350 | } | } |
| 351 | ||
| 352 | /** | /** |
| # | Line 327 function magento_api_customer_get_custom | Line 356 function magento_api_customer_get_custom |
| 356 | * @return array | * @return array |
| 357 | */ | */ |
| 358 | function magento_api_sales_order_list($filters) { | function magento_api_sales_order_list($filters) { |
| 359 | if ($session = _magento_api_get_session()) { | if ($session = _magento_api_get_session()) { |
| 360 | $order_list = xmlrpc(_magento_api_get_host(), 'call', $session, 'sales_order.list', array($filters)); | $order_list = xmlrpc(_magento_api_get_host(), 'call', $session, 'sales_order.list', array($filters)); |
| 361 | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Arguments = %args, Response = %response', array('%drupal_function' => 'magento_api_sales_order_list', '%magento_function' => 'sales_order.list', '%args' => serialize(array($filters)), '%response' => serialize($order_list)), WATCHDOG_NOTICE, $link = NULL); | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Arguments = %args, Response = %response', array('%drupal_function' => 'magento_api_sales_order_list', '%magento_function' => 'sales_order.list', '%args' => serialize(array($filters)), '%response' => serialize($order_list)), WATCHDOG_NOTICE, $link = NULL); |
| 362 | if (_magento_api_check_no_errors()) return $order_list; | if (_magento_api_check_no_errors()) return $order_list; |
| 363 | else { | else { |
| 364 | if (_magento_api_check_session_expire_error()) { | if (_magento_api_check_session_expire_error()) { |
| 365 | _magento_api_clear_session(); | _magento_api_clear_session(); |
| 366 | return magento_api_sales_order_list($filters); | return magento_api_sales_order_list($filters); |
| 367 | } | } |
| 368 | else return false; | else return false; |
| 369 | } | } |
| 370 | } | } |
| 371 | return false; | return false; |
| 372 | } | } |
| 373 | ||
| 374 | /** | /** |
| # | Line 349 function magento_api_sales_order_list($f | Line 378 function magento_api_sales_order_list($f |
| 378 | * @return array | * @return array |
| 379 | */ | */ |
| 380 | function magento_api_sales_order_info($orderId) { | function magento_api_sales_order_info($orderId) { |
| 381 | if ($session = _magento_api_get_session()) { | if ($session = _magento_api_get_session()) { |
| 382 | $order = xmlrpc(_magento_api_get_host(), 'call', $session, 'sales_order.info', array($orderId)); | $order = xmlrpc(_magento_api_get_host(), 'call', $session, 'sales_order.info', array($orderId)); |
| 383 | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Arguments = %args, Response = %response', array('%drupal_function' => 'magento_api_sales_order_info', '%magento_function' => 'sales_order.info', '%args' => serialize(array($orderId)), '%response' => serialize($order)), WATCHDOG_NOTICE, $link = NULL); | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Arguments = %args, Response = %response', array('%drupal_function' => 'magento_api_sales_order_info', '%magento_function' => 'sales_order.info', '%args' => serialize(array($orderId)), '%response' => serialize($order)), WATCHDOG_NOTICE, $link = NULL); |
| 384 | if (_magento_api_check_no_errors()) return $order; | if (_magento_api_check_no_errors()) return $order; |
| 385 | else { | else { |
| 386 | if (_magento_api_check_session_expire_error()) { | if (_magento_api_check_session_expire_error()) { |
| 387 | _magento_api_clear_session(); | _magento_api_clear_session(); |
| 388 | return magento_api_sales_order_info($orderId); | return magento_api_sales_order_info($orderId); |
| 389 | } | } |
| 390 | else return false; | else return false; |
| 391 | } | } |
| 392 | } | } |
| 393 | return false; | return false; |
| 394 | } | } |
| 395 | ||
| 396 | /** | /** |
| # | Line 370 function magento_api_sales_order_info($o | Line 399 function magento_api_sales_order_info($o |
| 399 | * @return array | * @return array |
| 400 | */ | */ |
| 401 | function magento_api_catalog_rules_list() { | function magento_api_catalog_rules_list() { |
| 402 | if ($session = _magento_api_get_session()) { | if ($session = _magento_api_get_session()) { |
| 403 | $rules_list = xmlrpc(_magento_api_get_host(), 'call', $session, 'rule.rulesList'); | $rules_list = xmlrpc(_magento_api_get_host(), 'call', $session, 'rule.rulesList'); |
| 404 | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Arguments = %args, Response = %response', array('%drupal_function' => 'magento_api_catalog_rules_list', '%magento_function' => 'rule.rulesList', '%args' => serialize(0), '%response' => serialize($rules_list)), WATCHDOG_NOTICE, $link = NULL); | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Arguments = %args, Response = %response', array('%drupal_function' => 'magento_api_catalog_rules_list', '%magento_function' => 'rule.rulesList', '%args' => serialize(0), '%response' => serialize($rules_list)), WATCHDOG_NOTICE, $link = NULL); |
| 405 | if (_magento_api_check_no_errors()) return $rules_list; | if (_magento_api_check_no_errors()) return $rules_list; |
| 406 | else { | else { |
| 407 | if (_magento_api_check_session_expire_error()) { | if (_magento_api_check_session_expire_error()) { |
| 408 | _magento_api_clear_session(); | _magento_api_clear_session(); |
| 409 | return magento_api_catalog_rules_list(); | return magento_api_catalog_rules_list(); |
| 410 | } | } |
| 411 | else return false; | else return false; |
| 412 | } | } |
| 413 | } | } |
| 414 | return false; | return false; |
| 415 | } | } |
| 416 | ||
| 417 | /** | /** |
| # | Line 393 function magento_api_catalog_rules_list( | Line 422 function magento_api_catalog_rules_list( |
| 422 | * @return array | * @return array |
| 423 | */ | */ |
| 424 | function magento_api_catalog_product_list($filters, $storeView) { | function magento_api_catalog_product_list($filters, $storeView) { |
| 425 | if ($session = _magento_api_get_session()) { | if ($session = _magento_api_get_session()) { |
| 426 | // $product_list = xmlrpc(_magento_api_get_host(), 'call', $session, 'product.list', array($filters, $storeView)); | // $product_list = xmlrpc(_magento_api_get_host(), 'call', $session, 'product.list', array($filters, $storeView)); |
| 427 | $product_list = xmlrpc(_magento_api_get_host(), 'call', $session, 'catalog.productsList', array($filters, $storeView)); | $product_list = xmlrpc(_magento_api_get_host(), 'call', $session, 'catalog.productsList', array($filters, $storeView)); |
| 428 | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Arguments = %args, Response = %response', array('%drupal_function' => 'magento_api_catalog_product_list', '%magento_function' => 'catalog.productsList', '%args' => serialize(array($filters, $storeView)), '%response' => serialize($product_list)), WATCHDOG_NOTICE, $link = NULL); | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Arguments = %args, Response = %response', array('%drupal_function' => 'magento_api_catalog_product_list', '%magento_function' => 'catalog.productsList', '%args' => serialize(array($filters, $storeView)), '%response' => serialize($product_list)), WATCHDOG_NOTICE, $link = NULL); |
| 429 | if (_magento_api_check_no_errors()) return $product_list; | if (_magento_api_check_no_errors()) return $product_list; |
| 430 | else { | else { |
| 431 | if (_magento_api_check_session_expire_error()) { | if (_magento_api_check_session_expire_error()) { |
| 432 | _magento_api_clear_session(); | _magento_api_clear_session(); |
| 433 | return magento_api_catalog_product_list($filters, $storeView); | return magento_api_catalog_product_list($filters, $storeView); |
| 434 | } | } |
| 435 | else return false; | else return false; |
| 436 | } | } |
| 437 | } | } |
| 438 | return false; | return false; |
| 439 | } | } |
| 440 | ||
| 441 | /** | /** |
| # | Line 417 function magento_api_catalog_product_lis | Line 446 function magento_api_catalog_product_lis |
| 446 | * @return array | * @return array |
| 447 | */ | */ |
| 448 | function magento_api_catalog_product_list_simple($filters, $storeView) { | function magento_api_catalog_product_list_simple($filters, $storeView) { |
| 449 | $product_list = magento_api_catalog_product_list($filters, $storeView); | $product_list = magento_api_catalog_product_list($filters, $storeView); |
| 450 | if ($product_list) { | if ($product_list) { |
| 451 | $result = array(); | $result = array(); |
| 452 | foreach ($product_list as $product) { | foreach ($product_list as $product) { |
| 453 | $result[$product['product_id']] = $product['name']; | $result[$product['entity_id']] = $product['name']; |
| 454 | } | } |
| 455 | return $result; | return $result; |
| 456 | } | } |
| 457 | return false; | return false; |
| 458 | } | } |
| 459 | ||
| 460 | /** | /** |
| # | Line 437 function magento_api_catalog_product_lis | Line 466 function magento_api_catalog_product_lis |
| 466 | * @return array | * @return array |
| 467 | */ | */ |
| 468 | function magento_api_catalog_product_info($product, $storeView = NULL, $attributes = NULL) { | function magento_api_catalog_product_info($product, $storeView = NULL, $attributes = NULL) { |
| 469 | if ($session = _magento_api_get_session()) { | if ($session = _magento_api_get_session()) { |
| 470 | $product_info = xmlrpc(_magento_api_get_host(), 'call', $session, 'product.info', array($product, $storeView, $attributes)); | $product_info = xmlrpc(_magento_api_get_host(), 'call', $session, 'product.info', array($product, $storeView, $attributes)); |
| 471 | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Arguments = %args, Response = %response', array('%drupal_function' => 'magento_api_catalog_product_info', '%magento_function' => 'product.info', '%args' => serialize(array($filters, $storeView, $attributes)), '%response' => serialize($product_info)), WATCHDOG_NOTICE, $link = NULL); | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Arguments = %args, Response = %response', array('%drupal_function' => 'magento_api_catalog_product_info', '%magento_function' => 'product.info', '%args' => serialize(array($filters, $storeView, $attributes)), '%response' => serialize($product_info)), WATCHDOG_NOTICE, $link = NULL); |
| 472 | if (_magento_api_check_no_errors()) return $product_info; | if (_magento_api_check_no_errors()) return $product_info; |
| 473 | else { | else { |
| 474 | if (_magento_api_check_session_expire_error()) { | if (_magento_api_check_session_expire_error()) { |
| 475 | _magento_api_clear_session(); | _magento_api_clear_session(); |
| 476 | return magento_api_catalog_product_info($product, $storeView, $attributes); | return magento_api_catalog_product_info($product, $storeView, $attributes); |
| 477 | } | } |
| 478 | else return false; | else return false; |
| 479 | } | } |
| 480 | } | } |
| 481 | return false; | return false; |
| 482 | } | } |
| 483 | ||
| 484 | /** | /** |
| # | Line 458 function magento_api_catalog_product_inf | Line 487 function magento_api_catalog_product_inf |
| 487 | * @return array | * @return array |
| 488 | */ | */ |
| 489 | function magento_api_directory_country_list() { | function magento_api_directory_country_list() { |
| 490 | if ($session = _magento_api_get_session()) { | if ($session = _magento_api_get_session()) { |
| 491 | $countries = xmlrpc(_magento_api_get_host(), 'call', $session, 'country.list'); | $countries = xmlrpc(_magento_api_get_host(), 'call', $session, 'country.list'); |
| 492 | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Arguments = %args, Response = %response', array('%drupal_function' => 'magento_api_directory_country_list', '%magento_function' => 'country.list', '%args' => serialize(0), '%response' => serialize($countries)), WATCHDOG_NOTICE, $link = NULL); | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Arguments = %args, Response = %response', array('%drupal_function' => 'magento_api_directory_country_list', '%magento_function' => 'country.list', '%args' => serialize(0), '%response' => serialize($countries)), WATCHDOG_NOTICE, $link = NULL); |
| 493 | if (_magento_api_check_no_errors()) return $countries; | if (_magento_api_check_no_errors()) return $countries; |
| 494 | else { | else { |
| 495 | if (_magento_api_check_session_expire_error()) { | if (_magento_api_check_session_expire_error()) { |
| 496 | _magento_api_clear_session(); | _magento_api_clear_session(); |
| 497 | return magento_api_directory_country_list(); | return magento_api_directory_country_list(); |
| 498 | } | } |
| 499 | else return false; | else return false; |
| 500 | } | } |
| 501 | } | } |
| 502 | return false; | return false; |
| 503 | } | |
| 504 | ||
| 505 | /** | |
| 506 | * Retrieve only allowed list of countries (localized) | |
| 507 | * | |
| 508 | * @return array | |
| 509 | */ | |
| 510 | function magento_api_directory_country_list_allowed() { | |
| 511 | if ($session = _magento_api_get_session()) { | |
| 512 | $countries = xmlrpc(_magento_api_get_host(), 'call', $session, 'config.allowedCountries'); | |
| 513 | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Arguments = %args, Response = %response', array('%drupal_function' => 'magento_api_directory_country_list_allowed', '%magento_function' => 'country.list', '%args' => serialize(0), '%response' => serialize($countries)), WATCHDOG_NOTICE, $link = NULL); | |
| 514 | if (_magento_api_check_no_errors()) return $countries; | |
| 515 | else { | |
| 516 | if (_magento_api_check_session_expire_error()) { | |
| 517 | _magento_api_clear_session(); | |
| 518 | return magento_api_directory_country_list_allowed(); | |
| 519 | } | |
| 520 | else return false; | |
| 521 | } | |
| 522 | } | |
| 523 | return false; | |
| 524 | } | } |
| 525 | ||
| 526 | /** | /** |
| # | Line 478 function magento_api_directory_country_l | Line 528 function magento_api_directory_country_l |
| 528 | * | * |
| 529 | * @return array | * @return array |
| 530 | */ | */ |
| 531 | function magento_api_directory_country_list_simple() { | function magento_api_directory_country_list_simple($onlyAllowed = FALSE) { |
| 532 | $countries = magento_api_directory_country_list(); | if ($onlyAllowed) { |
| 533 | if ($countries) { | $countries = magento_api_directory_country_list_allowed(); |
| 534 | $result = array(); | } else { |
| 535 | foreach ($countries as $country) { | $countries = magento_api_directory_country_list(); |
| 536 | $result[$country['country_id']] = $country['name']; | } |
| 537 | } | if ($countries) { |
| 538 | return $result; | $result = array(); |
| 539 | } | foreach ($countries as $country) { |
| 540 | return false; | $result[$country['country_id']] = $country['name']; |
| 541 | } | |
| 542 | return $result; | |
| 543 | } | |
| 544 | return false; | |
| 545 | } | } |
| 546 | /** | /** |
| 547 | * List of regions in specified country | * List of regions in specified country |
| # | Line 496 function magento_api_directory_country_l | Line 550 function magento_api_directory_country_l |
| 550 | * @return array | * @return array |
| 551 | */ | */ |
| 552 | function magento_api_directory_region_list($country) { | function magento_api_directory_region_list($country) { |
| 553 | if ($session = _magento_api_get_session()) { | if ($session = _magento_api_get_session()) { |
| 554 | $regions = xmlrpc(_magento_api_get_host(), 'call', $session, 'region.list', array($country)); | $regions = xmlrpc(_magento_api_get_host(), 'call', $session, 'region.list', array($country)); |
| 555 | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Arguments = %args, Response = %response', array('%drupal_function' => 'magento_api_directory_region_list', '%magento_function' => 'region.list', '%args' => serialize(array($country)), '%response' => serialize($regions)), WATCHDOG_NOTICE, $link = NULL); | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Arguments = %args, Response = %response', array('%drupal_function' => 'magento_api_directory_region_list', '%magento_function' => 'region.list', '%args' => serialize(array($country)), '%response' => serialize($regions)), WATCHDOG_NOTICE, $link = NULL); |
| 556 | if (_magento_api_check_no_errors()) return $regions; | if (_magento_api_check_no_errors()) return $regions; |
| 557 | else { | else { |
| 558 | if (_magento_api_check_session_expire_error()) { | if (_magento_api_check_session_expire_error()) { |
| 559 | _magento_api_clear_session(); | _magento_api_clear_session(); |
| 560 | return magento_api_directory_region_list($country); | return magento_api_directory_region_list($country); |
| 561 | } | } |
| 562 | else return false; | else return false; |
| 563 | } | } |
| 564 | } | } |
| 565 | return false; | return false; |
| 566 | } | } |
| 567 | ||
| 568 | /** | /** |
| # | Line 518 function magento_api_directory_region_li | Line 572 function magento_api_directory_region_li |
| 572 | * @return array | * @return array |
| 573 | */ | */ |
| 574 | function magento_api_sales_order_shipment_list($filters = NULL) { | function magento_api_sales_order_shipment_list($filters = NULL) { |
| 575 | if ($session = _magento_api_get_session()) { | if ($session = _magento_api_get_session()) { |
| 576 | $shipments = xmlrpc(_magento_api_get_host(), 'call', $session, 'order_shipment.list', array($filters)); | $shipments = xmlrpc(_magento_api_get_host(), 'call', $session, 'order_shipment.list', array($filters)); |
| 577 | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Arguments = %args, Response = %response', array('%drupal_function' => 'magento_api_sales_order_shipment_list', '%magento_function' => 'order_shipment.list', '%args' => serialize(array($filters)), '%response' => serialize($shipments)), WATCHDOG_NOTICE, $link = NULL); | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Arguments = %args, Response = %response', array('%drupal_function' => 'magento_api_sales_order_shipment_list', '%magento_function' => 'order_shipment.list', '%args' => serialize(array($filters)), '%response' => serialize($shipments)), WATCHDOG_NOTICE, $link = NULL); |
| 578 | if (_magento_api_check_no_errors()) return $shipments; | if (_magento_api_check_no_errors()) return $shipments; |
| 579 | else { | else { |
| 580 | if (_magento_api_check_session_expire_error()) { | if (_magento_api_check_session_expire_error()) { |
| 581 | _magento_api_clear_session(); | _magento_api_clear_session(); |
| 582 | return magento_api_sales_order_shipment_list($filters); | return magento_api_sales_order_shipment_list($filters); |
| 583 | } | } |
| 584 | else return false; | else return false; |
| 585 | } | } |
| 586 | } | } |
| 587 | return false; | return false; |
| 588 | } | } |
| 589 | ||
| 590 | /** | /** |
| # | Line 540 function magento_api_sales_order_shipmen | Line 594 function magento_api_sales_order_shipmen |
| 594 | * @return array | * @return array |
| 595 | */ | */ |
| 596 | function magento_api_sales_order_shipment_info($shipmentIncrementId) { | function magento_api_sales_order_shipment_info($shipmentIncrementId) { |
| 597 | if ($session = _magento_api_get_session()) { | if ($session = _magento_api_get_session()) { |
| 598 | $shipment = xmlrpc(_magento_api_get_host(), 'call', $session, 'order_shipment.info', array($shipmentIncrementId)); | $shipment = xmlrpc(_magento_api_get_host(), 'call', $session, 'order_shipment.info', array($shipmentIncrementId)); |
| 599 | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Arguments = %args, Response = %response', array('%drupal_function' => 'magento_api_sales_order_shipment_info', '%magento_function' => 'order_shipment.info', '%args' => serialize(array($shipmentIncrementId)), '%response' => serialize($shipment)), WATCHDOG_NOTICE, $link = NULL); | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Arguments = %args, Response = %response', array('%drupal_function' => 'magento_api_sales_order_shipment_info', '%magento_function' => 'order_shipment.info', '%args' => serialize(array($shipmentIncrementId)), '%response' => serialize($shipment)), WATCHDOG_NOTICE, $link = NULL); |
| 600 | if (_magento_api_check_no_errors()) return $shipment; | if (_magento_api_check_no_errors()) return $shipment; |
| 601 | else { | else { |
| 602 | if (_magento_api_check_session_expire_error()) { | if (_magento_api_check_session_expire_error()) { |
| 603 | _magento_api_clear_session(); | _magento_api_clear_session(); |
| 604 | return magento_api_sales_order_shipment_info($shipmentIncrementId); | return magento_api_sales_order_shipment_info($shipmentIncrementId); |
| 605 | } | } |
| 606 | else return false; | else return false; |
| 607 | } | } |
| 608 | } | } |
| 609 | return false; | return false; |
| 610 | } | } |
| 611 | ||
| 612 | /** | /** |
| # | Line 561 function magento_api_sales_order_shipmen | Line 615 function magento_api_sales_order_shipmen |
| 615 | * @return array | * @return array |
| 616 | */ | */ |
| 617 | function magento_api_shipment_list() { | function magento_api_shipment_list() { |
| 618 | if ($session = _magento_api_get_session()) { | if ($session = _magento_api_get_session()) { |
| 619 | $shipments = xmlrpc(_magento_api_get_host(), 'call', $session, 'shipment.list'); | $shipments = xmlrpc(_magento_api_get_host(), 'call', $session, 'shipment.list'); |
| 620 | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Arguments = %args, Response = %response', array('%drupal_function' => 'magento_api_shipment_list', '%magento_function' => 'shipment.list', '%args' => serialize(0), '%response' => serialize($shipments)), WATCHDOG_NOTICE, $link = NULL); | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Arguments = %args, Response = %response', array('%drupal_function' => 'magento_api_shipment_list', '%magento_function' => 'shipment.list', '%args' => serialize(0), '%response' => serialize($shipments)), WATCHDOG_NOTICE, $link = NULL); |
| 621 | if (_magento_api_check_no_errors()) return $shipments; | if (_magento_api_check_no_errors()) return $shipments; |
| 622 | else { | else { |
| 623 | if (_magento_api_check_session_expire_error()) { | if (_magento_api_check_session_expire_error()) { |
| 624 | _magento_api_clear_session(); | _magento_api_clear_session(); |
| 625 | return magento_api_shipment_list(); | return magento_api_shipment_list(); |
| 626 | } | } |
| 627 | else return false; | else return false; |
| 628 | } | } |
| 629 | ||
| 630 | } | } |
| 631 | return false; | return false; |
| 632 | } | } |
| 633 | ||
| 634 | /** | /** |
| # | Line 583 function magento_api_shipment_list() { | Line 637 function magento_api_shipment_list() { |
| 637 | * @return array | * @return array |
| 638 | */ | */ |
| 639 | function magento_api_shipment_list_simple() { | function magento_api_shipment_list_simple() { |
| 640 | $shipments = magento_api_shipment_list(); | $shipments = magento_api_shipment_list(); |
| 641 | if ($shipments) { | if ($shipments) { |
| 642 | $result = array(); | $result = array(); |
| 643 | foreach ($shipments as $key => $item) { | foreach ($shipments as $key => $item) { |
| 644 | if ($item['value'] != '') { | if ($item['value'] != '') { |
| 645 | $label = $item['label']; | $label = $item['label']; |
| 646 | foreach ($item['value'] as $method) { | foreach ($item['value'] as $method) { |
| 647 | $result[$method['value']] = $label.' - '.$method['label']; | $result[$method['value']] = $label.' - '.$method['label']; |
| 648 | } | } |
| 649 | } | } |
| 650 | } | } |
| 651 | return $result; | return $result; |
| 652 | } | } |
| 653 | return false; | return false; |
| 654 | } | } |
| 655 | ||
| 656 | /** | /** |
| # | Line 605 function magento_api_shipment_list_simpl | Line 659 function magento_api_shipment_list_simpl |
| 659 | * @return array | * @return array |
| 660 | */ | */ |
| 661 | function magento_api_payment_list() { | function magento_api_payment_list() { |
| 662 | if ($session = _magento_api_get_session()) { | if ($session = _magento_api_get_session()) { |
| 663 | $payments = xmlrpc(_magento_api_get_host(), 'call', $session, 'payment.list'); | $payments = xmlrpc(_magento_api_get_host(), 'call', $session, 'payment.list'); |
| 664 | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Arguments = %args, Response = %response', array('%drupal_function' => 'magento_api_payment_list', '%magento_function' => 'payment.list', '%args' => serialize(0), '%response' => serialize($payments)), WATCHDOG_NOTICE, $link = NULL); | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Arguments = %args, Response = %response', array('%drupal_function' => 'magento_api_payment_list', '%magento_function' => 'payment.list', '%args' => serialize(0), '%response' => serialize($payments)), WATCHDOG_NOTICE, $link = NULL); |
| 665 | if (_magento_api_check_no_errors()) return $payments; | if (_magento_api_check_no_errors()) return $payments; |
| 666 | else { | else { |
| 667 | if (_magento_api_check_session_expire_error()) { | if (_magento_api_check_session_expire_error()) { |
| 668 | _magento_api_clear_session(); | _magento_api_clear_session(); |
| 669 | return magento_api_payment_list(); | return magento_api_payment_list(); |
| 670 | } | } |
| 671 | else return false; | else return false; |
| 672 | } | } |
| 673 | ||
| 674 | } | } |
| 675 | return false; | return false; |
| 676 | } | } |
| 677 | ||
| 678 | /** | /** |
| # | Line 628 function magento_api_payment_list() { | Line 682 function magento_api_payment_list() { |
| 682 | * @return array | * @return array |
| 683 | */ | */ |
| 684 | function magento_api_order_create($orderData) { | function magento_api_order_create($orderData) { |
| 685 | if ($session = _magento_api_get_session()) { | $orderData['website_id'] = magento_stores_get_default_website(); |
| 686 | $order = xmlrpc(_magento_api_get_host(), 'call', $session, 'ext_order.create', array($orderData)); | if ($session = _magento_api_get_session()) { |
| 687 | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Arguments = %args, Response = %response', array('%drupal_function' => 'magento_api_order_create', '%magento_function' => 'ext_order.create', '%args' => serialize(array($orderData)), '%response' => serialize($order)), WATCHDOG_NOTICE, $link = NULL); | $order = xmlrpc(_magento_api_get_host(), 'call', $session, 'ext_order.create', array($orderData)); |
| 688 | if (_magento_api_check_no_errors()) return $order; | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Arguments = %args, Response = %response', array('%drupal_function' => 'magento_api_order_create', '%magento_function' => 'ext_order.create', '%args' => serialize(array($orderData)), '%response' => serialize($order)), WATCHDOG_NOTICE, $link = NULL); |
| 689 | else { | if (_magento_api_check_no_errors()) return $order; |
| 690 | if (_magento_api_check_session_expire_error()) { | else { |
| 691 | _magento_api_clear_session(); | if (_magento_api_check_session_expire_error()) { |
| 692 | return magento_api_order_create($orderData); | _magento_api_clear_session(); |
| 693 | } | return magento_api_order_create($orderData); |
| 694 | else return false; | } |
| 695 | } | else return false; |
| 696 | } | } |
| 697 | return false; | } |
| 698 | return false; | |
| 699 | } | |
| 700 | ||
| 701 | /** | |
| 702 | * Prepare new order | |
| 703 | * | |
| 704 | * @param array $orderData | |
| 705 | * @return array | |
| 706 | */ | |
| 707 | function magento_api_order_prepare($orderData) { | |
| 708 | $orderData['website_id'] = magento_stores_get_default_website(); | |
| 709 | if ($session = _magento_api_get_session()) { | |
| 710 | $order = xmlrpc(_magento_api_get_host(), 'call', $session, 'ext_order.prepare', array($orderData, false)); | |
| 711 | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Arguments = %args, Response = %response', array('%drupal_function' => 'magento_api_order_prepare', '%magento_function' => 'ext_order.prepare', '%args' => serialize(array($orderData, false)), '%response' => serialize($order)), WATCHDOG_NOTICE, $link = NULL); | |
| 712 | if (_magento_api_check_no_errors()) return $order; | |
| 713 | else { | |
| 714 | if (_magento_api_check_session_expire_error()) { | |
| 715 | _magento_api_clear_session(); | |
| 716 | return magento_api_order_prepare($orderData); | |
| 717 | } | |
| 718 | else return false; | |
| 719 | } | |
| 720 | } | |
| 721 | return false; | |
| 722 | } | } |
| 723 | ||
| 724 | /** | /** |
| # | Line 650 function magento_api_order_create($order | Line 728 function magento_api_order_create($order |
| 728 | * @return array | * @return array |
| 729 | */ | */ |
| 730 | function magento_api_quote_create($orderData) { | function magento_api_quote_create($orderData) { |
| 731 | if ($session = _magento_api_get_session()) { | $orderData['website_id'] = magento_stores_get_default_website(); |
| 732 | $quote = xmlrpc(_magento_api_get_host(), 'call', $session, 'quote.create', array($orderData)); | if ($session = _magento_api_get_session()) { |
| 733 | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Arguments = %args, Response = %response', array('%drupal_function' => 'magento_api_quote_create', '%magento_function' => 'quote.create', '%args' => serialize(array($orderData)), '%response' => serialize($quote)), WATCHDOG_NOTICE, $link = NULL); | $quote = xmlrpc(_magento_api_get_host(), 'call', $session, 'quote.create', array($orderData)); |
| 734 | if (_magento_api_check_no_errors()) return $quote; | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Arguments = %args, Response = %response', array('%drupal_function' => 'magento_api_quote_create', '%magento_function' => 'quote.create', '%args' => serialize(array($orderData)), '%response' => serialize($quote)), WATCHDOG_NOTICE, $link = NULL); |
| 735 | else { | if (_magento_api_check_no_errors()) return $quote; |
| 736 | if (_magento_api_check_session_expire_error()) { | else { |
| 737 | _magento_api_clear_session(); | if (_magento_api_check_session_expire_error()) { |
| 738 | return magento_api_quote_create($orderData); | _magento_api_clear_session(); |
| 739 | } | return magento_api_quote_create($orderData); |
| 740 | else return false; | } |
| 741 | } | else return false; |
| 742 | } | |
| 743 | ||
| 744 | } | } |
| 745 | return false; | return false; |
| 746 | } | } |
| 747 | ||
| 748 | /** | /** |
| # | Line 672 function magento_api_quote_create($order | Line 751 function magento_api_quote_create($order |
| 751 | * @return array | * @return array |
| 752 | */ | */ |
| 753 | function magento_api_payment_paypal_wps_account_info() { | function magento_api_payment_paypal_wps_account_info() { |
| 754 | if ($session = _magento_api_get_session()) { | if ($session = _magento_api_get_session()) { |
| 755 | $acc = xmlrpc(_magento_api_get_host(), 'call', $session, 'payment.paypal_wps_account_info'); | $acc = xmlrpc(_magento_api_get_host(), 'call', $session, 'payment.paypal_wps_account_info'); |
| 756 | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Arguments = %args, Response = %response', array('%drupal_function' => 'magento_api_payment_paypal_wps_account_info', '%magento_function' => 'payment.paypal_wps_account_info', '%args' => serialize(0), '%response' => serialize($acc)), WATCHDOG_NOTICE, $link = NULL); | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Arguments = %args, Response = %response', array('%drupal_function' => 'magento_api_payment_paypal_wps_account_info', '%magento_function' => 'payment.paypal_wps_account_info', '%args' => serialize(0), '%response' => serialize($acc)), WATCHDOG_NOTICE, $link = NULL); |
| 757 | if (_magento_api_check_no_errors()) return $acc; | if (_magento_api_check_no_errors()) return $acc; |
| 758 | else { | else { |
| 759 | if (_magento_api_check_session_expire_error()) { | if (_magento_api_check_session_expire_error()) { |
| 760 | _magento_api_clear_session(); | _magento_api_clear_session(); |
| 761 | return magento_api_payment_paypal_wps_account_info(); | return magento_api_payment_paypal_wps_account_info(); |
| 762 | } | } |
| 763 | else return false; | else return false; |
| 764 | } | } |
| 765 | ||
| 766 | } | } |
| 767 | return false; | return false; |
| 768 | } | } |
| 769 | ||
| 770 | /** | /** |
| # | Line 699 function magento_api_payment_paypal_wps_ | Line 778 function magento_api_payment_paypal_wps_ |
| 778 | * @return boolean | * @return boolean |
| 779 | */ | */ |
| 780 | function magento_api_sales_order_add_comment($orderIncrementId, $status, $comment, $notify) { | function magento_api_sales_order_add_comment($orderIncrementId, $status, $comment, $notify) { |
| 781 | if ($session = _magento_api_get_session()) { | if ($session = _magento_api_get_session()) { |
| 782 | $order = xmlrpc(_magento_api_get_host(), 'call', $session, 'order.addComment', array($orderIncrementId, $status, $comment, $notify)); | $order = xmlrpc(_magento_api_get_host(), 'call', $session, 'order.addComment', array($orderIncrementId, $status, $comment, $notify)); |
| 783 | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Arguments = %args, Response = %response', array('%drupal_function' => 'magento_api_sales_order_add_comment', '%magento_function' => 'order.addComment', '%args' => serialize(array($orderIncrementId, $status, $comment, $notify)), '%response' => serialize($order)), WATCHDOG_NOTICE, $link = NULL); | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Arguments = %args, Response = %response', array('%drupal_function' => 'magento_api_sales_order_add_comment', '%magento_function' => 'order.addComment', '%args' => serialize(array($orderIncrementId, $status, $comment, $notify)), '%response' => serialize($order)), WATCHDOG_NOTICE, $link = NULL); |
| 784 | if (_magento_api_check_no_errors()) return $order; | if (_magento_api_check_no_errors()) return $order; |
| 785 | else { | else { |
| 786 | if (_magento_api_check_session_expire_error()) { | if (_magento_api_check_session_expire_error()) { |
| 787 | _magento_api_clear_session(); | _magento_api_clear_session(); |
| 788 | return magento_api_sales_order_add_comment($orderIncrementId, $status, $comment, $notify); | return magento_api_sales_order_add_comment($orderIncrementId, $status, $comment, $notify); |
| 789 | } | } |
| 790 | else return false; | else return false; |
| 791 | } | } |
| 792 | ||
| 793 | } | } |
| 794 | return false; | return false; |
| 795 | } | } |
| 796 | ||
| 797 | /** | /** |
| # | Line 723 function magento_api_sales_order_add_com | Line 802 function magento_api_sales_order_add_com |
| 802 | * @return boolean | * @return boolean |
| 803 | */ | */ |
| 804 | function magento_api_sales_order_cancel($orderIncrementId) { | function magento_api_sales_order_cancel($orderIncrementId) { |
| 805 | if ($session = _magento_api_get_session()) { | if ($session = _magento_api_get_session()) { |
| 806 | $cancel = xmlrpc(_magento_api_get_host(), 'call', $session, 'order.cancel', array($orderIncrementId)); | $cancel = xmlrpc(_magento_api_get_host(), 'call', $session, 'order.cancel', array($orderIncrementId)); |
| 807 | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Arguments = %args, Response = %response', array('%drupal_function' => 'magento_api_sales_order_cancel', '%magento_function' => 'order.cancel', '%args' => serialize(array($orderIncrementId)), '%response' => serialize($cancel)), WATCHDOG_NOTICE, $link = NULL); | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Arguments = %args, Response = %response', array('%drupal_function' => 'magento_api_sales_order_cancel', '%magento_function' => 'order.cancel', '%args' => serialize(array($orderIncrementId)), '%response' => serialize($cancel)), WATCHDOG_NOTICE, $link = NULL); |
| 808 | if (_magento_api_check_no_errors()) return $cancel; | if (_magento_api_check_no_errors()) return $cancel; |
| 809 | else { | else { |
| 810 | if (_magento_api_check_session_expire_error()) { | if (_magento_api_check_session_expire_error()) { |
| 811 | _magento_api_clear_session(); | _magento_api_clear_session(); |
| 812 | return magento_api_sales_order_cancel($orderIncrementId); | return magento_api_sales_order_cancel($orderIncrementId); |
| 813 | } | } |
| 814 | else return false; | else return false; |
| 815 | } | } |
| 816 | } | } |
| 817 | return false; | return false; |
| 818 | } | } |
| 819 | ||
| 820 | /** | /** |
| # | Line 746 function magento_api_sales_order_cancel( | Line 825 function magento_api_sales_order_cancel( |
| 825 | * @return mixed | * @return mixed |
| 826 | */ | */ |
| 827 | function magento_api_config_info($path, $storeId) { | function magento_api_config_info($path, $storeId) { |
| 828 | if ($session = _magento_api_get_session()) { | if ($session = _magento_api_get_session()) { |
| 829 | $value = xmlrpc(_magento_api_get_host(), 'call', $session, 'config.info', array($path, $storeId)); | $value = xmlrpc(_magento_api_get_host(), 'call', $session, 'config.info', array($path, $storeId)); |
| 830 | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Arguments = %args, Response = %response', array('%drupal_function' => 'magento_api_config_info', '%magento_function' => 'config.info', '%args' => serialize(array($path, $storeId)), '%response' => serialize($value)), WATCHDOG_NOTICE, $link = NULL); | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Arguments = %args, Response = %response', array('%drupal_function' => 'magento_api_config_info', '%magento_function' => 'config.info', '%args' => serialize(array($path, $storeId)), '%response' => serialize($value)), WATCHDOG_NOTICE, $link = NULL); |
| 831 | if (_magento_api_check_no_errors()) return $value; | if (_magento_api_check_no_errors()) return $value; |
| 832 | else { | else { |
| 833 | if (_magento_api_check_session_expire_error()) { | if (_magento_api_check_session_expire_error()) { |
| 834 | _magento_api_clear_session(); | _magento_api_clear_session(); |
| 835 | return magento_api_config_info($path, $storeId); | return magento_api_config_info($path, $storeId); |
| 836 | } | } |
| 837 | else return false; | else return false; |
| 838 | } | } |
| 839 | } | } |
| 840 | return false; | return false; |
| 841 | } | } |
| 842 | ||
| 843 | /** | /** |
| # | Line 767 function magento_api_config_info($path, | Line 846 function magento_api_config_info($path, |
| 846 | * @return array | * @return array |
| 847 | */ | */ |
| 848 | function magento_api_config_websites() { | function magento_api_config_websites() { |
| 849 | if ($session = _magento_api_get_session()) { | if ($session = _magento_api_get_session()) { |
| 850 | $value = xmlrpc(_magento_api_get_host(), 'call', $session, 'config.websites'); | $value = xmlrpc(_magento_api_get_host(), 'call', $session, 'config.websites'); |
| 851 | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Response = %response', array('%drupal_function' => 'magento_api_config_websites', '%magento_function' => 'config.websites', '%response' => serialize($value)), WATCHDOG_NOTICE, $link = NULL); | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Response = %response', array('%drupal_function' => 'magento_api_config_websites', '%magento_function' => 'config.websites', '%response' => serialize($value)), WATCHDOG_NOTICE, $link = NULL); |
| 852 | if (_magento_api_check_no_errors()) return $value; | if (_magento_api_check_no_errors()) return $value; |
| 853 | else { | else { |
| 854 | if (_magento_api_check_session_expire_error()) { | if (_magento_api_check_session_expire_error()) { |
| 855 | _magento_api_clear_session(); | _magento_api_clear_session(); |
| 856 | return magento_api_config_websites(); | return magento_api_config_websites(); |
| 857 | } | } |
| 858 | else return false; | else return false; |
| 859 | } | } |
| 860 | } | } |
| 861 | return false; | return false; |
| 862 | } | } |
| 863 | ||
| 864 | /** | /** |
| # | Line 788 function magento_api_config_websites() { | Line 867 function magento_api_config_websites() { |
| 867 | * @return array | * @return array |
| 868 | */ | */ |
| 869 | function magento_api_config_stores() { | function magento_api_config_stores() { |
| 870 | if ($session = _magento_api_get_session()) { | if ($session = _magento_api_get_session()) { |
| 871 | $value = xmlrpc(_magento_api_get_host(), 'call', $session, 'config.stores'); | $value = xmlrpc(_magento_api_get_host(), 'call', $session, 'config.stores'); |
| 872 | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Response = %response', array('%drupal_function' => 'magento_api_config_stores', '%magento_function' => 'config.stores', '%response' => serialize($value)), WATCHDOG_NOTICE, $link = NULL); | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Response = %response', array('%drupal_function' => 'magento_api_config_stores', '%magento_function' => 'config.stores', '%response' => serialize($value)), WATCHDOG_NOTICE, $link = NULL); |
| 873 | if (_magento_api_check_no_errors()) return $value; | if (_magento_api_check_no_errors()) return $value; |
| 874 | else { | else { |
| 875 | if (_magento_api_check_session_expire_error()) { | if (_magento_api_check_session_expire_error()) { |
| 876 | _magento_api_clear_session(); | _magento_api_clear_session(); |
| 877 | return magento_api_config_stores(); | return magento_api_config_stores(); |
| 878 | } | } |
| 879 | else return false; | else return false; |
| 880 | } | } |
| 881 | } | } |
| 882 | return false; | return false; |
| 883 | } | } |
| 884 | ||
| 885 | /** | /** |
| # | Line 809 function magento_api_config_stores() { | Line 888 function magento_api_config_stores() { |
| 888 | * @return array | * @return array |
| 889 | */ | */ |
| 890 | function magento_api_config_store_views() { | function magento_api_config_store_views() { |
| 891 | if ($session = _magento_api_get_session()) { | if ($session = _magento_api_get_session()) { |
| 892 | $value = xmlrpc(_magento_api_get_host(), 'call', $session, 'config.storeViews'); | $value = xmlrpc(_magento_api_get_host(), 'call', $session, 'config.storeViews'); |
| 893 | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Response = %response', array('%drupal_function' => 'magento_api_config_store_views', '%magento_function' => 'config.storeViews', '%response' => serialize($value)), WATCHDOG_NOTICE, $link = NULL); | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Response = %response', array('%drupal_function' => 'magento_api_config_store_views', '%magento_function' => 'config.storeViews', '%response' => serialize($value)), WATCHDOG_NOTICE, $link = NULL); |
| 894 | if (_magento_api_check_no_errors()) return $value; | if (_magento_api_check_no_errors()) return $value; |
| 895 | else { | else { |
| 896 | if (_magento_api_check_session_expire_error()) { | if (_magento_api_check_session_expire_error()) { |
| 897 | _magento_api_clear_session(); | _magento_api_clear_session(); |
| 898 | return magento_api_config_store_views(); | return magento_api_config_store_views(); |
| 899 | } | } |
| 900 | else return false; | else return false; |
| 901 | } | } |
| 902 | } | } |
| 903 | return false; | return false; |
| 904 | } | } |
| 905 | ||
| 906 | /** | /** |
| # | Line 830 function magento_api_config_store_views( | Line 909 function magento_api_config_store_views( |
| 909 | * @return array | * @return array |
| 910 | */ | */ |
| 911 | function magento_api_catalog_category_tree() { | function magento_api_catalog_category_tree() { |
| 912 | if ($session = _magento_api_get_session()) { | if ($session = _magento_api_get_session()) { |
| 913 | // $value = xmlrpc(_magento_api_get_host(), 'call', $session, 'category.tree', array($parentId, $storeView)); | // $value = xmlrpc(_magento_api_get_host(), 'call', $session, 'category.tree', array($parentId, $storeView)); |
| 914 | $value = xmlrpc(_magento_api_get_host(), 'call', $session, 'category.tree'); | $value = xmlrpc(_magento_api_get_host(), 'call', $session, 'category.tree'); |
| 915 | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Arguments = %args, Response = %response', array('%drupal_function' => 'magento_api_catalog_category_tree', '%magento_function' => 'category.tree', '%args' => serialize(array($parentId, $storeView)), '%response' => serialize($value)), WATCHDOG_NOTICE, $link = NULL); | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Arguments = %args, Response = %response', array('%drupal_function' => 'magento_api_catalog_category_tree', '%magento_function' => 'category.tree', '%args' => serialize(array($parentId, $storeView)), '%response' => serialize($value)), WATCHDOG_NOTICE, $link = NULL); |
| 916 | if (_magento_api_check_no_errors()) return $value; | if (_magento_api_check_no_errors()) return $value; |
| 917 | else { | else { |
| 918 | if (_magento_api_check_session_expire_error()) { | if (_magento_api_check_session_expire_error()) { |
| 919 | _magento_api_clear_session(); | _magento_api_clear_session(); |
| 920 | return magento_api_catalog_category_tree(); | return magento_api_catalog_category_tree(); |
| 921 | } | } |
| 922 | else return false; | else return false; |
| 923 | } | } |
| 924 | } | } |
| 925 | return false; | return false; |
| 926 | } | } |
| 927 | ||
| 928 | /** | /** |
| # | Line 853 function magento_api_catalog_category_tr | Line 932 function magento_api_catalog_category_tr |
| 932 | * @return array | * @return array |
| 933 | */ | */ |
| 934 | function magento_api_catalog_product_attribute_list($setId) { | function magento_api_catalog_product_attribute_list($setId) { |
| 935 | if ($session = _magento_api_get_session()) { | if ($session = _magento_api_get_session()) { |
| 936 | $value = xmlrpc(_magento_api_get_host(), 'call', $session, 'product_attribute.list', array($setId)); | $value = xmlrpc(_magento_api_get_host(), 'call', $session, 'product_attribute.list', array($setId)); |
| 937 | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Arguments = %args, Response = %response', array('%drupal_function' => 'magento_api_catalog_product_attribute_list', '%magento_function' => 'product_attribute.list', '%args' => serialize(array($setId)), '%response' => serialize($value)), WATCHDOG_NOTICE, $link = NULL); | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Arguments = %args, Response = %response', array('%drupal_function' => 'magento_api_catalog_product_attribute_list', '%magento_function' => 'product_attribute.list', '%args' => serialize(array($setId)), '%response' => serialize($value)), WATCHDOG_NOTICE, $link = NULL); |
| 938 | if (_magento_api_check_no_errors()) return $value; | if (_magento_api_check_no_errors()) return $value; |
| 939 | else { | else { |
| 940 | if (_magento_api_check_session_expire_error()) { | if (_magento_api_check_session_expire_error()) { |
| 941 | _magento_api_clear_session(); | _magento_api_clear_session(); |
| 942 | return magento_api_catalog_product_attribute_list($setId); | return magento_api_catalog_product_attribute_list($setId); |
| 943 | } | } |
| 944 | else return false; | else return false; |
| 945 | } | } |
| 946 | } | } |
| 947 | return false; | return false; |
| 948 | } | } |
| 949 | ||
| 950 | /** | /** |
| 951 | * Retrieve attribute options | * Retrieve attribute options |
| 952 | * | * |
| 953 | * @param int $attributeId | * @param int $attributeId |
| 954 | * @param int $storeViewId | * @param int $storeViewId |
| 955 | * @return array | * @return array |
| 956 | */ | */ |
| 957 | function magento_api_catalog_product_attribute_options($attributeId, $storeView = NULL) { | function magento_api_catalog_product_attribute_options($attributeId, $storeView = NULL) { |
| 958 | if ($session = _magento_api_get_session()) { | if ($session = _magento_api_get_session()) { |
| 959 | $value = xmlrpc(_magento_api_get_host(), 'call', $session, 'product_attribute.options', array($attributeId, $storeView)); | $value = xmlrpc(_magento_api_get_host(), 'call', $session, 'product_attribute.options', array($attributeId, $storeView)); |
| 960 | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Arguments = %args, Response = %response', array('%drupal_function' => 'magento_api_catalog_product_attribute_options', '%magento_function' => 'product_attribute.options', '%args' => serialize(array($attributeId, $storeView)), '%response' => serialize($value)), WATCHDOG_NOTICE, $link = NULL); | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Arguments = %args, Response = %response', array('%drupal_function' => 'magento_api_catalog_product_attribute_options', '%magento_function' => 'product_attribute.options', '%args' => serialize(array($attributeId, $storeView)), '%response' => serialize($value)), WATCHDOG_NOTICE, $link = NULL); |
| 961 | if (_magento_api_check_no_errors()) return $value; | if (_magento_api_check_no_errors()) return $value; |
| 962 | else { | else { |
| 963 | if (_magento_api_check_session_expire_error()) { | if (_magento_api_check_session_expire_error()) { |
| 964 | _magento_api_clear_session(); | _magento_api_clear_session(); |
| 965 | return magento_api_catalog_product_attribute_options($attributeId, $storeViewId); | return magento_api_catalog_product_attribute_options($attributeId, $storeViewId); |
| 966 | } | } |
| 967 | else return false; | else return false; |
| 968 | } | } |
| 969 | } | } |
| 970 | return false; | return false; |
| 971 | } | } |
| 972 | ||
| 973 | /** | /** |
| 974 | * Retrieve list of product's images | * Retrieve list of product's images |
| 975 | * | * |
| 976 | * @param mixed $product - product ID or Sku | * @param mixed $product - product ID or Sku |
| 977 | * @param mixed $storeView - store view ID or code (optional) | * @param mixed $storeView - store view ID or code (optional) |
| 978 | * @return array | * @return array |
| 979 | */ | */ |
| 980 | function magento_api_catalog_product_media_list($product, $storeView = NULL) { | function magento_api_catalog_product_media_list($product, $storeView = NULL) { |
| 981 | if ($session = _magento_api_get_session()) { | if ($session = _magento_api_get_session()) { |
| 982 | $value = xmlrpc(_magento_api_get_host(), 'call', $session, 'product_media.list', array($product, $storeView)); | $value = xmlrpc(_magento_api_get_host(), 'call', $session, 'product_media.list', array($product, $storeView)); |
| 983 | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Arguments = %args, Response = %response', array('%drupal_function' => 'magento_api_catalog_product_media_list', '%magento_function' => 'product_media.list', '%args' => serialize(array($product, $storeView)), '%response' => serialize($value)), WATCHDOG_NOTICE, $link = NULL); | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Arguments = %args, Response = %response', array('%drupal_function' => 'magento_api_catalog_product_media_list', '%magento_function' => 'product_media.list', '%args' => serialize(array($product, $storeView)), '%response' => serialize($value)), WATCHDOG_NOTICE, $link = NULL); |
| 984 | if (_magento_api_check_no_errors()) return $value; | if (_magento_api_check_no_errors()) return $value; |
| 985 | else { | else { |
| 986 | if (_magento_api_check_session_expire_error()) { | if (_magento_api_check_session_expire_error()) { |
| 987 | _magento_api_clear_session(); | _magento_api_clear_session(); |
| 988 | return magento_api_catalog_product_media_list($product, $storeView); | return magento_api_catalog_product_media_list($product, $storeView); |
| 989 | } | } |
| 990 | else return false; | else return false; |
| 991 | } | } |
| 992 | } | } |
| 993 | return false; | return false; |
| 994 | } | } |
| 995 | ||
| 996 | /** | /** |
| 997 | * Retrieve product full info | * Retrieve product full info |
| 998 | * | * |
| 999 | * @param mixed $product - product ID or Sku | * @param mixed $product - product ID or Sku |
| 1000 | * @param mixed $storeView - store view ID or code (optional) | * @param mixed $storeView - store view ID or code (optional) |
| 1001 | * @return array | * @return array |
| 1002 | */ | */ |
| 1003 | function magento_api_catalog_product_full_info($product, $storeView) { | function magento_api_catalog_product_full_info($product, $storeView) { |
| 1004 | if ($session = _magento_api_get_session()) { | if ($session = _magento_api_get_session()) { |
| 1005 | $value = xmlrpc(_magento_api_get_host(), 'call', $session, 'catalog.productFullInfo', array($product, $storeView)); | $value = xmlrpc(_magento_api_get_host(), 'call', $session, 'catalog.productFullInfo', array($product, $storeView)); |
| 1006 | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Arguments = %args, Response = %response', array('%drupal_function' => 'magento_api_catalog_product_full_info', '%magento_function' => 'catalog.productFullInfo', '%args' => serialize(array($product, $storeView)), '%response' => serialize($value)), WATCHDOG_NOTICE, $link = NULL); | if (variable_get('magento_api_log', 0)) watchdog('magento_api', 'Drupal function = %drupal_function, Magento function = %magento_function, Arguments = %args, Response = %response', array('%drupal_function' => 'magento_api_catalog_product_full_info', '%magento_function' => 'catalog.productFullInfo', '%args' => serialize(array($product, $storeView)), '%response' => serialize($value)), WATCHDOG_NOTICE, $link = NULL); |
| 1007 | if (_magento_api_check_no_errors()) return $value; | if (_magento_api_check_no_errors()) return $value; |
| 1008 | else { | else { |
| 1009 | if (_magento_api_check_session_expire_error()) { | if (_magento_api_check_session_expire_error()) { |
| 1010 | _magento_api_clear_session(); | _magento_api_clear_session(); |
| 1011 | return magento_api_catalog_product_full_info($product, $storeView); | return magento_api_catalog_product_full_info($product, $storeView); |
| 1012 | } | } |
| 1013 | else return false; | else return false; |
| 1014 | } | } |
| 1015 | } | } |
| 1016 | return false; | return false; |
| 1017 | } | } |
| 1018 | /** | /** |
| 1019 | * Retrieve product actual price | * Retrieve product actual price |
| 1020 | * | * |
| 1021 | * @param mixed $product - product ID or Sku | * @param mixed $product - product ID or Sku |
| 1022 | * @param mixed $qty - product qty | * @param mixed $qty - product qty |
| 1023 | * @param mixed $groupId - Customer Group ID | * @param mixed $groupId - Customer Group ID |
| 1024 | * @param mixed $storeView - store view ID or code (optional) | * @param mixed $storeView - store view ID or code (optional) |
| 1025 | * @return mixed | * @return mixed |
| 1026 | */ | */ |
| 1027 | function magento_api_catalog_product_actual_price($product, $qty, $groupId, $storeView) { | function magento_api_catalog_product_actual_price($product, $qty, $groupId, $storeView) { |
| 1028 | if ($session = _magento_api_get_session()) { | if ($session = _magento_api_get_session()) { |