ebay.php (105685B)
1 <?php 2 class ControllerExtensionOpenbayEbay extends Controller { 3 public function install() { 4 $this->load->language('extension/openbay/ebay'); 5 $this->load->model('extension/openbay/ebay'); 6 $this->load->model('setting/setting'); 7 $this->load->model('setting/extension'); 8 $this->load->model('user/user_group'); 9 10 $this->model_user_user_group->addPermission($this->user->getGroupId(), 'access', 'extension/openbay/ebay_profile'); 11 $this->model_user_user_group->addPermission($this->user->getGroupId(), 'modify', 'extension/openbay/ebay_profile'); 12 $this->model_user_user_group->addPermission($this->user->getGroupId(), 'access', 'extension/openbay/ebay_template'); 13 $this->model_user_user_group->addPermission($this->user->getGroupId(), 'modify', 'extension/openbay/ebay_template'); 14 15 $this->model_extension_openbay_ebay->install(); 16 } 17 18 public function uninstall() { 19 $this->load->model('extension/openbay/ebay'); 20 $this->load->model('setting/setting'); 21 $this->load->model('setting/extension'); 22 23 $this->model_extension_openbay_ebay->uninstall(); 24 $this->model_setting_extension->uninstall('openbay', $this->request->get['extension']); 25 $this->model_setting_setting->deleteSetting($this->request->get['extension']); 26 } 27 28 public function index() { 29 $data = $this->load->language('extension/openbay/ebay'); 30 31 $this->document->setTitle($this->language->get('text_dashboard')); 32 $this->document->addScript('view/javascript/openbay/js/faq.js'); 33 34 $data['breadcrumbs'] = array(); 35 36 $data['breadcrumbs'][] = array( 37 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true), 38 'text' => $this->language->get('text_home'), 39 ); 40 41 $data['breadcrumbs'][] = array( 42 'href' => $this->url->link('marketplace/openbay', 'user_token=' . $this->session->data['user_token'], true), 43 'text' => $this->language->get('text_openbay'), 44 ); 45 46 $data['breadcrumbs'][] = array( 47 'href' => $this->url->link('extension/openbay/ebay', 'user_token=' . $this->session->data['user_token'], true), 48 'text' => $this->language->get('text_dashboard'), 49 ); 50 51 if (isset($this->session->data['success'])) { 52 $data['success'] = $this->session->data['success']; 53 unset($this->session->data['success']); 54 } else { 55 $data['success'] = ''; 56 } 57 58 $data['validation'] = $this->openbay->ebay->validate(); 59 $data['links_settings'] = $this->url->link('extension/openbay/ebay/settings', 'user_token=' . $this->session->data['user_token'], true); 60 $data['links_itemlink'] = $this->url->link('extension/openbay/ebay/viewItemLinks', 'user_token=' . $this->session->data['user_token'], true); 61 $data['links_subscribe'] = $this->url->link('extension/openbay/ebay/subscription', 'user_token=' . $this->session->data['user_token'], true); 62 $data['links_usage'] = $this->url->link('extension/openbay/ebay/viewUsage', 'user_token=' . $this->session->data['user_token'], true); 63 $data['links_itemimport'] = $this->url->link('extension/openbay/ebay/viewItemImport', 'user_token=' . $this->session->data['user_token'], true); 64 $data['links_orderimport'] = $this->url->link('extension/openbay/ebay/viewOrderImport', 'user_token=' . $this->session->data['user_token'], true); 65 $data['links_usage'] = $this->url->link('extension/openbay/ebay/viewUsage', 'user_token=' . $this->session->data['user_token'], true); 66 $data['links_sync'] = $this->url->link('extension/openbay/ebay/syncronise', 'user_token=' . $this->session->data['user_token'], true); 67 $data['links_linkmaintenance'] = $this->url->link('extension/openbay/ebay/viewItemLinkMaintenance', 'user_token=' . $this->session->data['user_token'], true); 68 $data['links_summary'] = $this->url->link('extension/openbay/ebay/summary', 'user_token=' . $this->session->data['user_token'], true); 69 $data['links_profile'] = $this->url->link('extension/openbay/ebay_profile/profileAll', 'user_token=' . $this->session->data['user_token'], true); 70 $data['links_template'] = $this->url->link('extension/openbay/ebay_template/listAll', 'user_token=' . $this->session->data['user_token'], true); 71 $data['link_signup'] = 'https://account.openbaypro.com/ebay/apiRegister/?endpoint=2&utm_source=opencart_install&utm_medium=dashboard&utm_campaign=ebay'; 72 73 $data['header'] = $this->load->controller('common/header'); 74 $data['column_left'] = $this->load->controller('common/column_left'); 75 $data['footer'] = $this->load->controller('common/footer'); 76 77 $this->response->setOutput($this->load->view('extension/openbay/ebay', $data)); 78 } 79 80 public function settings() { 81 $data = $this->load->language('extension/openbay/ebay_settings'); 82 83 $this->load->model('setting/setting'); 84 $this->load->model('extension/openbay/ebay'); 85 $this->load->model('localisation/currency'); 86 $this->load->model('localisation/order_status'); 87 88 if (($this->request->server['REQUEST_METHOD'] == 'POST') && ($this->validate())) { 89 $this->model_setting_setting->editSetting('ebay', $this->request->post); 90 $this->session->data['success'] = $this->language->get('text_success'); 91 $this->response->redirect($this->url->link('extension/openbay/ebay', 'user_token=' . $this->session->data['user_token'], true)); 92 } 93 94 $this->document->setTitle($this->language->get('heading_title')); 95 $this->document->addScript('view/javascript/openbay/js/faq.js'); 96 $data['breadcrumbs'] = array(); 97 98 $data['breadcrumbs'][] = array( 99 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true), 100 'text' => $this->language->get('text_home'), 101 ); 102 103 $data['breadcrumbs'][] = array( 104 'href' => $this->url->link('marketplace/openbay', 'user_token=' . $this->session->data['user_token'], true), 105 'text' => $this->language->get('text_openbay'), 106 ); 107 108 $data['breadcrumbs'][] = array( 109 'href' => $this->url->link('extension/openbay/ebay', 'user_token=' . $this->session->data['user_token'], true), 110 'text' => $this->language->get('text_ebay'), 111 ); 112 113 $data['breadcrumbs'][] = array( 114 'href' => $this->url->link('extension/openbay/ebay/settings', 'user_token=' . $this->session->data['user_token'], true), 115 'text' => $this->language->get('heading_title'), 116 ); 117 118 $data['action'] = $this->url->link('extension/openbay/ebay/settings', 'user_token=' . $this->session->data['user_token'], true); 119 $data['cancel'] = $this->url->link('extension/openbay/ebay', 'user_token=' . $this->session->data['user_token'], true); 120 $data['link_signup'] = 'https://account.openbaypro.com/ebay/apiRegister/?endpoint=2&utm_source=opencart_install&utm_medium=settings&utm_campaign=ebay'; 121 $data['link_token_renew'] = 'https://account.openbaypro.com/ebay/apiRenew/?utm_source=opencart_install&utm_medium=settings&utm_campaign=ebaytoken'; 122 $data['link_update'] = 'https://account.openbaypro.com/ebay/apiUpdate/?utm_source=opencart_install&utm_medium=settings&utm_campaign=ebayupdate'; 123 124 if (isset($this->request->post['ebay_def_currency'])) { 125 $data['ebay_def_currency'] = $this->request->post['ebay_def_currency']; 126 } else { 127 $data['ebay_def_currency'] = $this->config->get('ebay_def_currency'); 128 } 129 $data['currency_list'] = $this->model_localisation_currency->getCurrencies(); 130 131 $data['user_token'] = $this->session->data['user_token']; 132 133 if (isset($this->error['warning'])) { 134 $data['error_warning'] = $this->error['warning']; 135 } else { 136 $data['error_warning'] = ''; 137 } 138 139 if (isset($this->request->post['ebay_status'])) { 140 $data['ebay_status'] = $this->request->post['ebay_status']; 141 } else { 142 $data['ebay_status'] = $this->config->get('ebay_status'); 143 } 144 145 if (isset($this->request->post['ebay_token'])) { 146 $data['ebay_token'] = trim($this->request->post['ebay_token']); 147 } else { 148 $data['ebay_token'] = trim($this->config->get('ebay_token')); 149 } 150 151 if (isset($this->request->post['ebay_secret'])) { 152 $data['ebay_secret'] = trim($this->request->post['ebay_secret']); 153 } else { 154 $data['ebay_secret'] = trim($this->config->get('ebay_secret')); 155 } 156 157 if (isset($this->request->post['ebay_encryption_key'])) { 158 $data['ebay_encryption_key'] = trim($this->request->post['ebay_encryption_key']); 159 } else { 160 $data['ebay_encryption_key'] = trim($this->config->get('ebay_encryption_key')); 161 } 162 163 if (isset($this->request->post['ebay_encryption_iv'])) { 164 $data['ebay_encryption_iv'] = trim($this->request->post['ebay_encryption_iv']); 165 } else { 166 $data['ebay_encryption_iv'] = trim($this->config->get('ebay_encryption_iv')); 167 } 168 169 if (isset($this->request->post['ebay_enditems'])) { 170 $data['ebay_enditems'] = $this->request->post['ebay_enditems']; 171 } else { 172 $data['ebay_enditems'] = $this->config->get('ebay_enditems'); 173 } 174 175 if (isset($this->request->post['ebay_relistitems'])) { 176 $data['ebay_relistitems'] = $this->request->post['ebay_relistitems']; 177 } else { 178 $data['ebay_relistitems'] = $this->config->get('ebay_relistitems'); 179 } 180 181 if (isset($this->request->post['ebay_disable_nostock'])) { 182 $data['ebay_disable_nostock'] = $this->request->post['ebay_disable_nostock']; 183 } else { 184 $data['ebay_disable_nostock'] = $this->config->get('ebay_disable_nostock'); 185 } 186 if (isset($this->request->post['ebay_logging'])) { 187 $data['ebay_logging'] = $this->request->post['ebay_logging']; 188 } else { 189 $data['ebay_logging'] = $this->config->get('ebay_logging'); 190 } 191 192 if (isset($this->request->post['ebay_created_hours'])) { 193 $data['ebay_created_hours'] = $this->request->post['ebay_created_hours']; 194 } else { 195 $data['ebay_created_hours'] = $this->config->get('ebay_created_hours'); 196 } 197 198 if (isset($this->request->post['ebay_time_offset'])) { 199 $data['ebay_time_offset'] = $this->request->post['ebay_time_offset']; 200 } else { 201 $data['ebay_time_offset'] = $this->config->get('ebay_time_offset'); 202 } 203 204 if (isset($this->request->post['ebay_update_notify'])) { 205 $data['ebay_update_notify'] = $this->request->post['ebay_update_notify']; 206 } else { 207 $data['ebay_update_notify'] = $this->config->get('ebay_update_notify'); 208 } 209 210 if (isset($this->request->post['ebay_confirm_notify'])) { 211 $data['ebay_confirm_notify'] = $this->request->post['ebay_confirm_notify']; 212 } else { 213 $data['ebay_confirm_notify'] = $this->config->get('ebay_confirm_notify'); 214 } 215 216 if (isset($this->request->post['ebay_confirmadmin_notify'])) { 217 $data['ebay_confirmadmin_notify'] = $this->request->post['ebay_confirmadmin_notify']; 218 } else { 219 $data['ebay_confirmadmin_notify'] = $this->config->get('ebay_confirmadmin_notify'); 220 } 221 222 if (isset($this->request->post['ebay_email_brand_disable'])) { 223 $data['ebay_email_brand_disable'] = $this->request->post['ebay_email_brand_disable']; 224 } else { 225 $data['ebay_email_brand_disable'] = $this->config->get('ebay_email_brand_disable'); 226 } 227 228 if (isset($this->request->post['ebay_itm_link'])) { 229 $data['ebay_itm_link'] = $this->request->post['ebay_itm_link']; 230 } else { 231 $data['ebay_itm_link'] = $this->config->get('ebay_itm_link'); 232 } 233 234 if (isset($this->request->post['ebay_stock_allocate'])) { 235 $data['ebay_stock_allocate'] = $this->request->post['ebay_stock_allocate']; 236 } else { 237 $data['ebay_stock_allocate'] = $this->config->get('ebay_stock_allocate'); 238 } 239 240 if (isset($this->request->post['ebay_create_date'])) { 241 $data['ebay_create_date'] = $this->request->post['ebay_create_date']; 242 } else { 243 $data['ebay_create_date'] = $this->config->get('ebay_create_date'); 244 } 245 246 $data['durations'] = array( 247 'Days_1' => $data['text_listing_1day'], 248 'Days_3' => $data['text_listing_3day'], 249 'Days_5' => $data['text_listing_5day'], 250 'Days_7' => $data['text_listing_7day'], 251 'Days_10' => $data['text_listing_10day'], 252 'Days_30' => $data['text_listing_30day'], 253 'GTC' => $data['text_listing_gtc'] 254 ); 255 256 if (isset($this->request->post['ebay_duration'])) { 257 $data['ebay_duration'] = $this->request->post['ebay_duration']; 258 } else { 259 $data['ebay_duration'] = $this->config->get('ebay_duration'); 260 } 261 262 if (isset($this->request->post['ebay_measurement'])) { 263 $data['ebay_measurement'] = $this->request->post['ebay_measurement']; 264 } else { 265 $data['ebay_measurement'] = $this->config->get('ebay_measurement'); 266 } 267 268 if (isset($this->request->post['ebay_default_addressformat'])) { 269 $data['ebay_default_addressformat'] = $this->request->post['ebay_default_addressformat']; 270 } else { 271 $data['ebay_default_addressformat'] = $this->config->get('ebay_default_addressformat'); 272 } 273 274 $data['payment_options'] = $this->model_extension_openbay_ebay->getPaymentTypes(); 275 276 if (isset($this->request->post['ebay_payment_types'])) { 277 $data['ebay_payment_types'] = $this->request->post['ebay_payment_types']; 278 } else { 279 $data['ebay_payment_types'] = $this->config->get('ebay_payment_types'); 280 } 281 282 if (isset($this->request->post['ebay_payment_instruction'])) { 283 $data['ebay_payment_instruction'] = $this->request->post['ebay_payment_instruction']; 284 } else { 285 $data['ebay_payment_instruction'] = $this->config->get('ebay_payment_instruction'); 286 } 287 288 if (isset($this->request->post['ebay_payment_paypal_address'])) { 289 $data['ebay_payment_paypal_address'] = $this->request->post['ebay_payment_paypal_address']; 290 } else { 291 $data['ebay_payment_paypal_address'] = $this->config->get('ebay_payment_paypal_address'); 292 } 293 294 if (isset($this->request->post['ebay_payment_immediate'])) { 295 $data['ebay_payment_immediate'] = $this->request->post['ebay_payment_immediate']; 296 } else { 297 $data['ebay_payment_immediate'] = $this->config->get('ebay_payment_immediate'); 298 } 299 300 if (isset($this->request->post['ebay_tax_listing'])) { 301 $data['ebay_tax_listing'] = $this->request->post['ebay_tax_listing']; 302 } else { 303 $data['ebay_tax_listing'] = $this->config->get('ebay_tax_listing'); 304 } 305 306 if (isset($this->request->post['ebay_tax'])) { 307 $data['ebay_tax'] = $this->request->post['ebay_tax']; 308 } else { 309 $data['ebay_tax'] = $this->config->get('ebay_tax'); 310 } 311 312 if (isset($this->request->post['ebay_import_unpaid'])) { 313 $data['ebay_import_unpaid'] = $this->request->post['ebay_import_unpaid']; 314 } else { 315 $data['ebay_import_unpaid'] = $this->config->get('ebay_import_unpaid'); 316 } 317 318 if (isset($this->request->post['ebay_status_partial_refund_id'])) { 319 $data['ebay_status_partial_refund_id'] = $this->request->post['ebay_status_partial_refund_id']; 320 } else { 321 $data['ebay_status_partial_refund_id'] = $this->config->get('ebay_status_partial_refund_id'); 322 } 323 324 if (isset($this->request->post['ebay_status_import_id'])) { 325 $data['ebay_status_import_id'] = $this->request->post['ebay_status_import_id']; 326 } else { 327 $data['ebay_status_import_id'] = $this->config->get('ebay_status_import_id'); 328 } 329 330 if (isset($this->request->post['ebay_status_paid_id'])) { 331 $data['ebay_status_paid_id'] = $this->request->post['ebay_status_paid_id']; 332 } else { 333 $data['ebay_status_paid_id'] = $this->config->get('ebay_status_paid_id'); 334 } 335 336 if (isset($this->request->post['ebay_status_shipped_id'])) { 337 $data['ebay_status_shipped_id'] = $this->request->post['ebay_status_shipped_id']; 338 } else { 339 $data['ebay_status_shipped_id'] = $this->config->get('ebay_status_shipped_id'); 340 } 341 342 if (isset($this->request->post['ebay_status_cancelled_id'])) { 343 $data['ebay_status_cancelled_id'] = $this->request->post['ebay_status_cancelled_id']; 344 } else { 345 $data['ebay_status_cancelled_id'] = $this->config->get('ebay_status_cancelled_id'); 346 } 347 348 if (isset($this->request->post['ebay_status_refunded_id'])) { 349 $data['ebay_status_refunded_id'] = $this->request->post['ebay_status_refunded_id']; 350 } else { 351 $data['ebay_status_refunded_id'] = $this->config->get('ebay_status_refunded_id'); 352 } 353 354 $data['api_server'] = $this->openbay->ebay->getServer(); 355 $data['order_statuses'] = $this->model_localisation_order_status->getOrderStatuses(); 356 $data['measurement_types'] = $this->openbay->ebay->getSetting('measurement_types'); 357 358 $data['header'] = $this->load->controller('common/header'); 359 $data['column_left'] = $this->load->controller('common/column_left'); 360 $data['footer'] = $this->load->controller('common/footer'); 361 362 $this->response->setOutput($this->load->view('extension/openbay/ebay_settings', $data)); 363 } 364 365 public function updateSettings() { 366 set_time_limit(0); 367 368 $json = $this->openbay->ebay->updateSettings(); 369 370 $this->response->addHeader('Content-Type: application/json'); 371 $this->response->setOutput(json_encode($json)); 372 } 373 374 public function updateCategories() { 375 set_time_limit(0); 376 377 $json = $this->openbay->ebay->updateCategories(); 378 379 $this->response->addHeader('Content-Type: application/json'); 380 $this->response->setOutput(json_encode($json)); 381 } 382 383 public function updateStore() { 384 set_time_limit(0); 385 386 $json = $this->openbay->ebay->updateStore(); 387 388 $this->response->addHeader('Content-Type: application/json'); 389 $this->response->setOutput(json_encode($json)); 390 } 391 392 public function getCategories() { 393 $this->load->model('extension/openbay/ebay'); 394 395 $json = $this->model_extension_openbay_ebay->getCategory($this->request->get['parent']); 396 397 $this->response->addHeader('Content-Type: application/json'); 398 $this->response->setOutput(json_encode($json)); 399 } 400 401 public function getSuggestedCategories() { 402 $this->load->model('extension/openbay/ebay'); 403 404 $this->load->language('extension/openbay/ebay'); 405 406 $json = $this->model_extension_openbay_ebay->getSuggestedCategories($this->request->get['qry']); 407 408 if (empty($json['data'])) { 409 $json['msg'] = $this->language->get('error_category_nosuggestions'); 410 } 411 412 $this->response->addHeader('Content-Type: application/json'); 413 $this->response->setOutput(json_encode($json)); 414 } 415 416 public function getShippingService() { 417 $this->load->model('extension/openbay/ebay'); 418 419 $json = $this->model_extension_openbay_ebay->getShippingService($this->request->get['loc'], $this->request->get['type']); 420 421 $this->response->addHeader('Content-Type: application/json'); 422 $this->response->setOutput(json_encode($json)); 423 } 424 425 public function getEbayCategorySpecifics() { 426 $this->load->model('extension/openbay/ebay'); 427 $this->load->model('catalog/product'); 428 $this->load->model('catalog/attribute'); 429 430 $response = $this->model_extension_openbay_ebay->getEbayCategorySpecifics($this->request->get['category_id']); 431 432 $recommendation_data = array(); 433 434 if (isset($response['data']['Recommendations']['NameRecommendation'])) { 435 if (isset($response['data']['Recommendations']['NameRecommendation']['Name'])) { 436 $recommendations = array($response['data']['Recommendations']['NameRecommendation']); 437 } else { 438 $recommendations = $response['data']['Recommendations']['NameRecommendation']; 439 } 440 441 foreach ($recommendations as $name_recommendation_key => $name_recommendation) { 442 $recommendation_data_option = array( 443 'name' => $name_recommendation['Name'], 444 'validation' => 445 array( 446 'max_values' => $name_recommendation['ValidationRules']['MaxValues'], 447 'selection_mode' => $name_recommendation['ValidationRules']['SelectionMode'], 448 ), 449 'unmatched_value' => '', 450 ); 451 452 if (isset($name_recommendation['ValueRecommendation'])) { 453 if (!isset($name_recommendation['ValueRecommendation']['Value'])) { 454 foreach($name_recommendation['ValueRecommendation'] as $value_recommendation_key => $value_recommendation) { 455 $recommendation_data_option['options'][] = $value_recommendation['Value']; 456 } 457 } 458 } 459 460 $recommendation_data[] = $recommendation_data_option; 461 } 462 463 if (isset($this->request->get['product_id'])) { 464 $product_attributes = $this->model_catalog_product->getProductAttributes($this->request->get['product_id']); 465 466 foreach ($product_attributes as $product_attribute) { 467 $attribute_info = $this->model_catalog_attribute->getAttribute($product_attribute['attribute_id']); 468 469 if ($attribute_info) { 470 // search the ebay attribute results for a match 471 foreach($recommendation_data as $name_recommendation_key => $name_recommendation) { 472 if (strtolower($attribute_info['name']) == strtolower($name_recommendation['name'])) { 473 $preset_match_found = false; 474 475 if (isset($name_recommendation['options'])) { 476 foreach($name_recommendation['options'] as $value_recommendation_key => $value_recommendation) { 477 if (strtolower($value_recommendation) == strtolower($product_attribute['product_attribute_description'][$this->config->get('config_language_id')]['text'])) { 478 $preset_match_found = $value_recommendation_key; 479 } 480 } 481 } 482 483 if ($preset_match_found === false) { 484 if ($name_recommendation['validation']['selection_mode'] == 'FreeText') { 485 $recommendation_data[$name_recommendation_key]['unmatched_value'] = $product_attribute['product_attribute_description'][$this->config->get('config_language_id')]['text']; 486 } 487 } else { 488 $recommendation_data[$name_recommendation_key]['matched_value_key'] = $preset_match_found; 489 } 490 } 491 } 492 } 493 } 494 } 495 } 496 497 $json = array( 498 'data' => $recommendation_data, 499 'msg' => $response['msg'], 500 'error' => $response['error'], 501 ); 502 503 $this->response->addHeader('Content-Type: application/json'); 504 $this->response->setOutput(json_encode($json)); 505 } 506 507 public function getCategoryFeatures() { 508 $this->load->model('extension/openbay/ebay'); 509 510 $json = $this->model_extension_openbay_ebay->getCategoryFeatures($this->request->get['category']); 511 512 $this->response->addHeader('Content-Type: application/json'); 513 $this->response->setOutput(json_encode($json)); 514 } 515 516 public function searchEbayCatalog() { 517 $this->load->language('extension/openbay/ebay'); 518 $this->load->model('extension/openbay/ebay_product'); 519 520 $response = $this->model_extension_openbay_ebay_product->searchEbayCatalog($this->request->post['search'], $this->request->post['category_id']); 521 522 $json = array('error' => false, 'error_message' => ''); 523 524 if (isset($response['ack'])) { 525 if ($response['ack'] == 'Success') { 526 $json['results'] = (int)$response['productSearchResult']['paginationOutput']['totalEntries']; 527 $json['page'] = (int)$response['productSearchResult']['paginationOutput']['pageNumber']; 528 $json['page_total'] = (int)$response['productSearchResult']['paginationOutput']['totalPages']; 529 530 if (isset($response['productSearchResult']['products'])) { 531 $json['products'] = $response['productSearchResult']['products']; 532 } else { 533 $json = array('error' => true, 'error_message' => $this->language->get('error_no_products')); 534 } 535 } else { 536 if (isset($response['errorMessage']['error']['message'])) { 537 $json = array('error' => true, 'error_message' => $response['errorMessage']['error']['message']); 538 } else { 539 $json = array('error' => true, 'error_message' => $this->language->get('error_loading_catalog')); 540 } 541 } 542 } else { 543 $json = array('error' => true, 'error_message' => $this->language->get('error_generic_fail')); 544 } 545 546 $this->response->addHeader('Content-Type: application/json'); 547 $this->response->setOutput(json_encode($json)); 548 } 549 550 public function summary() { 551 $data = $this->load->language('extension/openbay/ebay_summary'); 552 553 $this->document->setTitle($this->language->get('heading_title')); 554 $this->document->addScript('view/javascript/openbay/js/faq.js'); 555 556 $data['breadcrumbs'] = array(); 557 558 $data['breadcrumbs'][] = array( 559 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true), 560 'text' => $this->language->get('text_home'), 561 ); 562 563 $data['breadcrumbs'][] = array( 564 'href' => $this->url->link('marketplace/openbay', 'user_token=' . $this->session->data['user_token'], true), 565 'text' => $this->language->get('text_openbay'), 566 ); 567 568 $data['breadcrumbs'][] = array( 569 'href' => $this->url->link('extension/openbay/ebay', 'user_token=' . $this->session->data['user_token'], true), 570 'text' => $this->language->get('text_ebay'), 571 ); 572 573 $data['breadcrumbs'][] = array( 574 'href' => $this->url->link('extension/openbay/ebay/summary', 'user_token=' . $this->session->data['user_token'], true), 575 'text' => $data['heading_title'], 576 ); 577 578 $data['return'] = $this->url->link('extension/openbay/ebay', 'user_token=' . $this->session->data['user_token'], true); 579 $data['validation'] = $this->openbay->ebay->validate(); 580 $data['user_token'] = $this->session->data['user_token']; 581 582 $data['header'] = $this->load->controller('common/header'); 583 $data['column_left'] = $this->load->controller('common/column_left'); 584 $data['footer'] = $this->load->controller('common/footer'); 585 586 $this->response->setOutput($this->load->view('extension/openbay/ebay_summary', $data)); 587 } 588 589 public function getSellerSummary() { 590 $this->load->model('extension/openbay/ebay'); 591 592 $json = $this->model_extension_openbay_ebay->getSellerSummary(); 593 594 $this->response->addHeader('Content-Type: application/json'); 595 $this->response->setOutput(json_encode($json)); 596 } 597 598 public function verifyCredentials() { 599 $this->load->model('extension/openbay/ebay'); 600 601 $json = $this->model_extension_openbay_ebay->verifyCredentials(); 602 603 $this->response->addHeader('Content-Type: application/json'); 604 $this->response->setOutput(json_encode($json)); 605 } 606 607 public function viewItemImport() { 608 $this->load->model('extension/openbay/ebay_product'); 609 610 $data = $this->load->language('extension/openbay/ebay_import'); 611 612 $this->document->setTitle($this->language->get('heading_title')); 613 $this->document->addScript('view/javascript/openbay/js/faq.js'); 614 615 $data['breadcrumbs'] = array(); 616 617 $data['breadcrumbs'][] = array( 618 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true), 619 'text' => $this->language->get('text_home'), 620 ); 621 622 $data['breadcrumbs'][] = array( 623 'href' => $this->url->link('marketplace/openbay', 'user_token=' . $this->session->data['user_token'], true), 624 'text' => $this->language->get('text_openbay'), 625 ); 626 627 $data['breadcrumbs'][] = array( 628 'href' => $this->url->link('extension/openbay/ebay', 'user_token=' . $this->session->data['user_token'], true), 629 'text' => $this->language->get('text_ebay'), 630 ); 631 632 $data['breadcrumbs'][] = array( 633 'href' => $this->url->link('extension/openbay/ebay/viewItemImport', 'user_token=' . $this->session->data['user_token'], true), 634 'text' => $this->language->get('heading_title'), 635 ); 636 637 $data['return'] = $this->url->link('extension/openbay/ebay', 'user_token=' . $this->session->data['user_token'], true); 638 $data['validation'] = $this->openbay->ebay->validate(); 639 $data['user_token'] = $this->session->data['user_token']; 640 $data['maintenance'] = $this->config->get('config_maintenance'); 641 $data['image_import'] = $this->model_extension_openbay_ebay_product->countImportImages(); 642 $data['ini_setting_post_max_size'] = ini_get('post_max_size'); 643 $data['ini_setting_memory_limit'] = ini_get('memory_limit'); 644 $data['image_import_link'] = $this->url->link('extension/openbay/ebay/getImportImages', 'user_token=' . $this->session->data['user_token'], true); 645 646 $data['header'] = $this->load->controller('common/header'); 647 $data['column_left'] = $this->load->controller('common/column_left'); 648 $data['footer'] = $this->load->controller('common/footer'); 649 650 $this->response->setOutput($this->load->view('extension/openbay/ebay_item_import', $data)); 651 } 652 653 public function importItems() { 654 $data = array( 655 'adv' => $this->request->get['advanced'], 656 'c' => 1, 657 'd' => $this->request->get['desc'], 658 'n' => $this->request->get['note'], 659 'cat' => $this->request->get['categories'], 660 ); 661 662 $this->openbay->ebay->callNoResponse('setup/getItemsMain/', $data); 663 664 $json = array('msg' => 'ok'); 665 666 $this->response->addHeader('Content-Type: application/json'); 667 $this->response->setOutput(json_encode($json)); 668 } 669 670 public function getImportImages() { 671 set_time_limit(0); 672 $this->openbay->ebay->getImages(); 673 674 $json = array('error' => false, 'msg' => 'OK'); 675 676 $this->response->addHeader('Content-Type: application/json'); 677 $this->response->setOutput(json_encode($json)); 678 } 679 680 public function importOrdersManual() { 681 $this->openbay->ebay->callNoResponse('order/getOrdersManual/'); 682 683 $json = array('msg' => 'ok'); 684 685 $this->response->addHeader('Content-Type: application/json'); 686 $this->response->setOutput(json_encode($json)); 687 } 688 689 public function getProductStock() { 690 $this->load->model('extension/openbay/ebay'); 691 692 $json = $this->model_extension_openbay_ebay->getProductStock($this->request->get['pid']); 693 694 $this->response->addHeader('Content-Type: application/json'); 695 $this->response->setOutput(json_encode($json)); 696 } 697 698 public function setProductStock() { 699 $this->load->model('extension/openbay/ebay'); 700 $this->load->model('catalog/product'); 701 702 $product = $this->model_catalog_product->getProduct($this->request->get['product_id']); 703 704 $json = array(); 705 706 if ($product['subtract'] == 1) { 707 $this->openbay->ebay->productUpdateListen($this->request->get['product_id']); 708 709 $json['error'] = false; 710 $json['msg'] = 'ok'; 711 } else { 712 $this->load->language('extension/openbay/ebay_links'); 713 714 $json['error'] = true; 715 $json['msg'] = $this->language->get('error_subtract_setting'); 716 } 717 718 $this->response->addHeader('Content-Type: application/json'); 719 $this->response->setOutput(json_encode($json)); 720 } 721 722 public function getPlans() { 723 $this->load->model('extension/openbay/ebay'); 724 725 $json = $this->model_extension_openbay_ebay->getPlans(); 726 727 $this->response->addHeader('Content-Type: application/json'); 728 $this->response->setOutput(json_encode($json)); 729 } 730 731 public function getMyPlan() { 732 $this->load->model('extension/openbay/ebay'); 733 734 $json = $this->model_extension_openbay_ebay->getMyPlan(); 735 736 $this->response->addHeader('Content-Type: application/json'); 737 $this->response->setOutput(json_encode($json)); 738 } 739 740 public function subscription() { 741 $data = $this->load->language('extension/openbay/ebay_subscription'); 742 743 $this->document->setTitle($this->language->get('heading_title')); 744 $this->document->addScript('view/javascript/openbay/js/faq.js'); 745 746 $data['breadcrumbs'] = array(); 747 748 $data['breadcrumbs'][] = array( 749 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true), 750 'text' => $this->language->get('text_home'), 751 ); 752 753 $data['breadcrumbs'][] = array( 754 'href' => $this->url->link('marketplace/openbay', 'user_token=' . $this->session->data['user_token'], true), 755 'text' => $this->language->get('text_openbay'), 756 ); 757 758 $data['breadcrumbs'][] = array( 759 'href' => $this->url->link('extension/openbay/ebay', 'user_token=' . $this->session->data['user_token'], true), 760 'text' => $this->language->get('text_ebay'), 761 ); 762 763 $data['breadcrumbs'][] = array( 764 'href' => $this->url->link('extension/openbay/ebay/subscription', 'user_token=' . $this->session->data['user_token'], true), 765 'text' => $this->language->get('heading_title'), 766 ); 767 768 $data['return'] = $this->url->link('extension/openbay/ebay', 'user_token=' . $this->session->data['user_token'], true); 769 $data['user_token'] = $this->session->data['user_token']; 770 $data['obp_token'] = $this->config->get('ebay_token'); 771 772 $data['header'] = $this->load->controller('common/header'); 773 $data['column_left'] = $this->load->controller('common/column_left'); 774 $data['footer'] = $this->load->controller('common/footer'); 775 776 $this->response->setOutput($this->load->view('extension/openbay/ebay_subscription', $data)); 777 } 778 779 public function viewUsage() { 780 $data = $this->load->language('extension/openbay/ebay_usage'); 781 782 $this->document->setTitle($this->language->get('heading_title')); 783 $this->document->addScript('view/javascript/openbay/js/faq.js'); 784 785 $data['breadcrumbs'] = array(); 786 787 $data['breadcrumbs'][] = array( 788 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true), 789 'text' => $this->language->get('text_home'), 790 ); 791 792 $data['breadcrumbs'][] = array( 793 'href' => $this->url->link('marketplace/openbay', 'user_token=' . $this->session->data['user_token'], true), 794 'text' => $this->language->get('text_openbay'), 795 ); 796 797 $data['breadcrumbs'][] = array( 798 'href' => $this->url->link('extension/openbay/ebay', 'user_token=' . $this->session->data['user_token'], true), 799 'text' => $this->language->get('text_ebay'), 800 ); 801 802 $data['breadcrumbs'][] = array( 803 'href' => $this->url->link('extension/openbay/ebay/view_usage', 'user_token=' . $this->session->data['user_token'], true), 804 'text' => $this->language->get('heading_title'), 805 ); 806 807 $data['return'] = $this->url->link('extension/openbay/ebay', 'user_token=' . $this->session->data['user_token'], true); 808 $data['user_token'] = $this->session->data['user_token']; 809 $data['obp_token'] = $this->config->get('ebay_token'); 810 811 $data['header'] = $this->load->controller('common/header'); 812 $data['column_left'] = $this->load->controller('common/column_left'); 813 $data['footer'] = $this->load->controller('common/footer'); 814 815 $this->response->setOutput($this->load->view('extension/openbay/ebay_usage', $data)); 816 } 817 818 public function getUsage() { 819 $this->load->model('extension/openbay/ebay'); 820 821 $json = $this->model_extension_openbay_ebay->getUsage(); 822 $json['html'] = base64_decode($json['html']); 823 $json['lasterror'] = $this->openbay->ebay->lasterror; 824 $json['lastmsg'] = $this->openbay->ebay->lastmsg; 825 826 $this->response->addHeader('Content-Type: application/json'); 827 $this->response->setOutput(json_encode($json)); 828 } 829 830 public function viewOrderImport() { 831 $data = $this->load->language('extension/openbay/ebay_orders'); 832 833 $this->document->setTitle($this->language->get('heading_title')); 834 $this->document->addScript('view/javascript/openbay/js/faq.js'); 835 836 $data['breadcrumbs'] = array(); 837 838 $data['breadcrumbs'][] = array( 839 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true), 840 'text' => $this->language->get('text_home'), 841 ); 842 843 $data['breadcrumbs'][] = array( 844 'href' => $this->url->link('marketplace/openbay', 'user_token=' . $this->session->data['user_token'], true), 845 'text' => $this->language->get('text_openbay'), 846 ); 847 848 $data['breadcrumbs'][] = array( 849 'href' => $this->url->link('extension/openbay/ebay', 'user_token=' . $this->session->data['user_token'], true), 850 'text' => $this->language->get('text_ebay'), 851 ); 852 853 $data['breadcrumbs'][] = array( 854 'href' => $this->url->link('extension/openbay/ebay/viewOrderImport', 'user_token=' . $this->session->data['user_token'], true), 855 'text' => $this->language->get('heading_title'), 856 ); 857 858 $data['return'] = $this->url->link('extension/openbay/ebay', 'user_token=' . $this->session->data['user_token'], true); 859 $data['validation'] = $this->openbay->ebay->validate(); 860 $data['user_token'] = $this->session->data['user_token']; 861 862 $data['header'] = $this->load->controller('common/header'); 863 $data['column_left'] = $this->load->controller('common/column_left'); 864 $data['footer'] = $this->load->controller('common/footer'); 865 866 $this->response->setOutput($this->load->view('extension/openbay/ebay_order_import', $data)); 867 } 868 869 public function syncronise() { 870 $data = $this->load->language('extension/openbay/ebay_syncronise'); 871 872 $this->document->setTitle($this->language->get('heading_title')); 873 $this->document->addScript('view/javascript/openbay/js/faq.js'); 874 875 $data['breadcrumbs'] = array(); 876 877 $data['breadcrumbs'][] = array( 878 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true), 879 'text' => $this->language->get('text_home'), 880 ); 881 882 $data['breadcrumbs'][] = array( 883 'href' => $this->url->link('marketplace/openbay', 'user_token=' . $this->session->data['user_token'], true), 884 'text' => $this->language->get('text_openbay'), 885 ); 886 887 $data['breadcrumbs'][] = array( 888 'href' => $this->url->link('extension/openbay/ebay', 'user_token=' . $this->session->data['user_token'], true), 889 'text' => $this->language->get('text_ebay'), 890 ); 891 892 $data['breadcrumbs'][] = array( 893 'href' => $this->url->link('extension/openbay/ebay/syncronise', 'user_token=' . $this->session->data['user_token'], true), 894 'text' => $this->language->get('heading_title'), 895 ); 896 897 $data['return'] = $this->url->link('extension/openbay/ebay', 'user_token=' . $this->session->data['user_token'], true); 898 $data['validation'] = $this->openbay->ebay->validate(); 899 $data['user_token'] = $this->session->data['user_token']; 900 901 if (isset($this->session->data['warning'])) { 902 $data['error_warning'] = $this->session->data['warning']; 903 } else { 904 $data['error_warning'] = ''; 905 } 906 907 $data['header'] = $this->load->controller('common/header'); 908 $data['column_left'] = $this->load->controller('common/column_left'); 909 $data['footer'] = $this->load->controller('common/footer'); 910 911 $this->response->setOutput($this->load->view('extension/openbay/ebay_syncronise', $data)); 912 } 913 914 public function viewItemLinks() { 915 $this->load->model('extension/openbay/ebay'); 916 917 $data = $this->load->language('extension/openbay/ebay_links'); 918 919 $this->document->setTitle($this->language->get('heading_title')); 920 $this->document->addScript('view/javascript/openbay/js/faq.js'); 921 922 $data['breadcrumbs'] = array(); 923 924 $data['breadcrumbs'][] = array( 925 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true), 926 'text' => $this->language->get('text_home'), 927 ); 928 929 $data['breadcrumbs'][] = array( 930 'href' => $this->url->link('marketplace/openbay', 'user_token=' . $this->session->data['user_token'], true), 931 'text' => $this->language->get('text_openbay'), 932 ); 933 934 $data['breadcrumbs'][] = array( 935 'href' => $this->url->link('extension/openbay/ebay', 'user_token=' . $this->session->data['user_token'], true), 936 'text' => $this->language->get('text_ebay'), 937 ); 938 939 $data['breadcrumbs'][] = array( 940 'href' => $this->url->link('extension/openbay/ebay/viewItemLinks', 'user_token=' . $this->session->data['user_token'], true), 941 'text' => $this->language->get('heading_title'), 942 ); 943 944 $data['cancel'] = $this->url->link('extension/openbay/ebay', 'user_token=' . $this->session->data['user_token'], true); 945 $data['edit_url'] = $this->url->link('extension/openbay/ebay/edit', 'user_token=' . $this->session->data['user_token'] . '&product_id=', true); 946 $data['validation'] = $this->openbay->ebay->validate(); 947 $data['user_token'] = $this->session->data['user_token']; 948 949 $total_linked = $this->model_extension_openbay_ebay->totalLinked(); 950 951 if (isset($this->request->get['linked_item_page'])){ 952 $linked_item_page = (int)$this->request->get['linked_item_page']; 953 } else { 954 $linked_item_page = 1; 955 } 956 957 if (isset($this->request->get['linked_item_limit'])){ 958 $linked_item_limit = (int)$this->request->get['linked_item_limit']; 959 } else { 960 $linked_item_limit = 100; 961 } 962 963 $pagination = new Pagination(); 964 $pagination->total = $total_linked; 965 $pagination->page = $linked_item_page; 966 $pagination->limit = 100; 967 $pagination->text = $this->language->get('text_pagination'); 968 $pagination->url = $this->url->link('extension/openbay/ebay/viewItemLinks', 'user_token=' . $this->session->data['user_token'] . '&linked_item_page={page}', true); 969 970 $data['pagination'] = $pagination->render(); 971 972 $data['linked_items'] = $this->model_extension_openbay_ebay->loadLinked($linked_item_limit, $linked_item_page); 973 974 $data['header'] = $this->load->controller('common/header'); 975 $data['column_left'] = $this->load->controller('common/column_left'); 976 $data['footer'] = $this->load->controller('common/footer'); 977 978 $this->response->setOutput($this->load->view('extension/openbay/ebay_item_link', $data)); 979 } 980 981 public function saveItemLink() { 982 $this->load->model('extension/openbay/ebay'); 983 984 $json = $this->model_extension_openbay_ebay->saveItemLink($this->request->get); 985 986 $this->response->addHeader('Content-Type: application/json'); 987 $this->response->setOutput(json_encode($json)); 988 } 989 990 public function removeItemLink() { 991 $this->load->language('extension/openbay/ebay'); 992 993 $this->openbay->ebay->removeItemByProductId($this->request->get['product_id']); 994 995 $json = array('error' => false, 'msg' => $this->language->get('item_link_removed')); 996 997 $this->response->addHeader('Content-Type: application/json'); 998 $this->response->setOutput(json_encode($json)); 999 } 1000 1001 public function loadUnlinked(){ 1002 set_time_limit(0); 1003 1004 $this->load->model('extension/openbay/ebay'); 1005 1006 $filter = array(); 1007 1008 if (isset($this->request->post['filter_variant']) && !empty($this->request->post['filter_variant'])) { 1009 $filter['variants'] = (int)$this->request->post['filter_variant']; 1010 } 1011 1012 if (isset($this->request->post['filter_title']) && !empty($this->request->post['filter_title'])) { 1013 $filter['title'] = (string)$this->request->post['filter_title']; 1014 } 1015 1016 if (isset($this->request->post['filter_qty_min']) && !empty($this->request->post['filter_qty_min'])) { 1017 $filter['qty_min'] = (int)$this->request->post['filter_qty_min']; 1018 } 1019 1020 if (isset($this->request->post['filter_qty_max']) && !empty($this->request->post['filter_qty_max'])) { 1021 $filter['qty_max'] = (int)$this->request->post['filter_qty_max']; 1022 } 1023 1024 $data = $this->model_extension_openbay_ebay->loadUnlinked(200, $this->request->get['page'], $filter); 1025 1026 if (!empty($data)) { 1027 $data['more_pages'] = 1; 1028 1029 if ($data['next_page'] > $data['max_page']){ 1030 $data['more_pages'] = 0; 1031 } 1032 1033 $json['data'] = $data; 1034 } else { 1035 $json['data'] = null; 1036 } 1037 1038 $this->response->addHeader('Content-Type: application/json'); 1039 $this->response->setOutput(json_encode($json)); 1040 } 1041 1042 public function loadLinkedStatus(){ 1043 set_time_limit(0); 1044 1045 $this->load->model('extension/openbay/ebay'); 1046 1047 $json['data'] = ''; 1048 if (isset($this->request->post['item_id']) && !empty($this->request->post['item_id'])){ 1049 $data = $this->model_extension_openbay_ebay->loadLinkedStatus($this->request->post['item_id']); 1050 1051 if (!empty($data)) { 1052 $json['data'] = $data; 1053 } 1054 } 1055 1056 $this->response->addHeader('Content-Type: application/json'); 1057 $this->response->setOutput(json_encode($json)); 1058 } 1059 1060 private function validate() { 1061 if (!$this->user->hasPermission('modify', 'extension/openbay/ebay')) { 1062 $this->error['warning'] = $this->language->get('error_permission'); 1063 } 1064 1065 return !$this->error; 1066 } 1067 1068 private function checkConfig() { 1069 if ($this->config->get('ebay_token') == '' || $this->config->get('ebay_secret') == '') { 1070 return false; 1071 } else { 1072 return true; 1073 } 1074 } 1075 1076 public function edit() { 1077 if ($this->checkConfig() == true) { 1078 if (!empty($this->request->get['product_id'])) { 1079 $data = $this->load->language('extension/openbay/ebay_edit'); 1080 1081 $this->load->model('catalog/product'); 1082 $this->load->model('tool/image'); 1083 $this->load->model('catalog/manufacturer'); 1084 $this->load->model('extension/openbay/ebay'); 1085 $this->load->model('extension/openbay/ebay_product'); 1086 1087 $this->document->setTitle($data['heading_title']); 1088 $this->document->addScript('view/javascript/openbay/js/faq.js'); 1089 1090 $data['action'] = $this->url->link('extension/openbay/ebay/create', 'user_token=' . $this->session->data['user_token'], true); 1091 $data['cancel'] = $this->url->link('marketplace/openbay/items', 'user_token=' . $this->session->data['user_token'], true); 1092 $data['view_link'] = $this->config->get('ebay_itm_link') . $this->openbay->ebay->getEbayItemId($this->request->get['product_id']); 1093 $data['user_token'] = $this->session->data['user_token']; 1094 $data['product_id'] = $this->request->get['product_id']; 1095 1096 $data['breadcrumbs'] = array(); 1097 1098 $data['breadcrumbs'][] = array( 1099 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true), 1100 'text' => $this->language->get('text_home'), 1101 ); 1102 1103 $data['breadcrumbs'][] = array( 1104 'href' => $this->url->link('marketplace/openbay', 'user_token=' . $this->session->data['user_token'], true), 1105 'text' => $this->language->get('text_openbay'), 1106 ); 1107 1108 $data['breadcrumbs'][] = array( 1109 'href' => $this->url->link('extension/openbay/ebay', 'user_token=' . $this->session->data['user_token'], true), 1110 'text' => $this->language->get('text_ebay'), 1111 ); 1112 1113 $data['breadcrumbs'][] = array( 1114 'href' => $this->url->link('extension/openbay/ebay/edit', 'user_token=' . $this->session->data['user_token'] . '&product_id=' . $this->request->get['product_id'], true), 1115 'text' => $this->language->get('heading_title'), 1116 ); 1117 1118 $data['header'] = $this->load->controller('common/header'); 1119 $data['column_left'] = $this->load->controller('common/column_left'); 1120 $data['footer'] = $this->load->controller('common/footer'); 1121 1122 $this->response->setOutput($this->load->view('extension/openbay/ebay_edit', $data)); 1123 } else { 1124 $this->response->redirect($this->url->link('marketplace/openbay/items', 'user_token=' . $this->session->data['user_token'], true)); 1125 } 1126 } 1127 } 1128 1129 public function editLoad() { 1130 $this->load->model('catalog/product'); 1131 $this->load->model('extension/openbay/ebay_product'); 1132 $this->load->model('tool/image'); 1133 1134 $item_id = $this->openbay->ebay->getEbayItemId($this->request->get['product_id']); 1135 1136 if (!empty($item_id)) { 1137 $listings = $this->openbay->ebay->getEbayListing($item_id); 1138 $stock = $this->openbay->ebay->getProductStockLevel($this->request->get['product_id']); 1139 $reserve = $this->openbay->ebay->getReserve($this->request->get['product_id'], $item_id); 1140 $options = array(); 1141 1142 $product_info = $this->model_catalog_product->getProduct($this->request->get['product_id']); 1143 1144 if ($this->openbay->addonLoad('openstock') && $product_info['has_option'] == 1) { 1145 $this->load->model('extension/module/openstock'); 1146 $data['addon']['openstock'] = true; 1147 $product_info['options'] = $this->model_setting_module_openstock->getVariants($this->request->get['product_id']); 1148 $product_info['option_groups'] = $this->model_extension_openbay_ebay_product->getProductOptions($this->request->get['product_id']); 1149 1150 $t = array(); 1151 $t_rel = array(); 1152 1153 foreach($product_info['option_groups'] as $group) { 1154 $t_tmp = array(); 1155 1156 foreach($group['product_option_value'] as $group_node) { 1157 $t_tmp[$group_node['option_value_id']] = $group_node['name']; 1158 $t_rel[$group_node['product_option_value_id']] = $group['name']; 1159 } 1160 1161 $t[] = array('name' => $group['name'], 'child' => $t_tmp); 1162 } 1163 1164 if (!isset($listings['variations']['Variation'][1])) { 1165 $listings['variations']['Variation'] = array($listings['variations']['Variation']); 1166 } 1167 1168 foreach($product_info['options'] as $option) { 1169 $option['base64'] = base64_encode(serialize($option['option_values'])); 1170 $option_reserve = $this->openbay->ebay->getReserve($this->request->get['product_id'], $item_id, $option['sku']); 1171 if ($option_reserve == false) { 1172 $option['reserve'] = 0; 1173 } else { 1174 $option['reserve'] = $this->openbay->ebay->getReserve($this->request->get['product_id'], $item_id, $option['sku']); 1175 } 1176 1177 $ebay_listing = ''; 1178 1179 foreach($listings['variations']['Variation'] as $listing) { 1180 1181 $sku = (isset($listing['SKU']) ? $listing['SKU'] : ''); 1182 1183 if ($sku != '' && $sku == $option['sku']) { 1184 $listing['StartPrice'] = number_format($listing['StartPrice'], 2, '.', ''); 1185 $listing['Quantity'] = $listing['Quantity'] - $listing['SellingStatus']['QuantitySold']; 1186 1187 $ebay_listing = $listing; 1188 } 1189 } 1190 1191 $options[] = array('ebay' => $ebay_listing, 'local' => $option, 'sku' => $option['sku'], 'product_option_variant_id' => $option['product_option_variant_id']); 1192 } 1193 1194 //unset variants that dont appear on eBay 1195 $options_inactive = array(); 1196 foreach($options as $k => $option) { 1197 if (empty($option['ebay'])) { 1198 $options_inactive[] = $options[$k]; 1199 unset($options[$k]); 1200 } 1201 } 1202 1203 $variant = array( 1204 'variant' => 1, 1205 'data' => array( 1206 'group_information' => array( 1207 'option_groups' => base64_encode(serialize($t)), 1208 'option_group_relationship' => base64_encode(serialize($t_rel)), 1209 ), 1210 'options' => $options, 1211 'options_inactive' => $options_inactive 1212 ) 1213 ); 1214 1215 } else { 1216 $variant = array('variant' => 0, 'data' => ''); 1217 } 1218 1219 if ($reserve == false) { 1220 $reserve = 0; 1221 } 1222 1223 $data = array( 1224 'listing' => $listings, 1225 'stock' => $stock, 1226 'reserve' => $reserve, 1227 'variant' => $variant, 1228 'product' => $product_info 1229 ); 1230 1231 if (!empty($listings)) { 1232 $this->response->addHeader('Content-Type: application/json'); 1233 $this->response->setOutput(json_encode(array('error' => false, 'data' => $data))); 1234 } else { 1235 $this->response->addHeader('Content-Type: application/json'); 1236 $this->response->setOutput(json_encode(array('error' => true))); 1237 } 1238 } else { 1239 $this->response->addHeader('Content-Type: application/json'); 1240 $this->response->setOutput(json_encode(array('error' => true))); 1241 } 1242 } 1243 1244 public function editSave() { 1245 if ($this->checkConfig() == true && $this->request->server['REQUEST_METHOD'] == 'POST') { 1246 1247 $this->load->model('extension/openbay/ebay'); 1248 1249 $json = $this->model_extension_openbay_ebay->editSave($this->request->post); 1250 1251 $this->response->addHeader('Content-Type: application/json'); 1252 $this->response->setOutput(json_encode($json)); 1253 } else { 1254 $this->response->redirect($this->url->link('marketplace/openbay/items', 'user_token=' . $this->session->data['user_token'], true)); 1255 } 1256 } 1257 1258 public function create() { 1259 if ($this->checkConfig() == true) { 1260 if (!empty($this->request->get['product_id'])) { 1261 $data = $this->load->language('extension/openbay/ebay_new'); 1262 1263 $this->load->model('catalog/product'); 1264 $this->load->model('tool/image'); 1265 $this->load->model('catalog/manufacturer'); 1266 $this->load->model('extension/openbay/ebay'); 1267 $this->load->model('extension/openbay/ebay_template'); 1268 $this->load->model('extension/openbay/ebay_product'); 1269 $this->load->model('extension/openbay/ebay_profile'); 1270 1271 $this->document->setTitle($data['heading_title']); 1272 $this->document->addScript('view/javascript/openbay/js/faq.js'); 1273 1274 $data['action'] = $this->url->link('extension/openbay/ebay/create', 'user_token=' . $this->session->data['user_token'], true); 1275 $data['cancel'] = $this->url->link('marketplace/openbay/items', 'user_token=' . $this->session->data['user_token'], true); 1276 $data['user_token'] = $this->session->data['user_token']; 1277 1278 $data['breadcrumbs'] = array(); 1279 $data['breadcrumbs'][] = array( 1280 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true), 1281 'text' => $this->language->get('text_home'), 1282 ); 1283 $data['breadcrumbs'][] = array( 1284 'href' => $this->url->link('marketplace/openbay', 'user_token=' . $this->session->data['user_token'], true), 1285 'text' => $this->language->get('text_openbay'), 1286 ); 1287 $data['breadcrumbs'][] = array( 1288 'href' => $this->url->link('extension/openbay/ebay', 'user_token=' . $this->session->data['user_token'], true), 1289 'text' => $this->language->get('text_ebay'), 1290 ); 1291 1292 $data['breadcrumbs'][] = array( 1293 'href' => $this->url->link('extension/openbay/ebay/create', 'user_token=' . $this->session->data['user_token'] . '&product_id=' . $this->request->get['product_id'], true), 1294 'text' => $this->language->get('heading_title'), 1295 ); 1296 1297 $product_info = $this->model_catalog_product->getProduct($this->request->get['product_id']); 1298 1299 $setting = array(); 1300 1301 $setting['dispatch_times'] = $this->openbay->ebay->getSetting('dispatch_time_max'); 1302 1303 if (is_array($setting['dispatch_times'])) { 1304 ksort($setting['dispatch_times']); 1305 } 1306 1307 $setting['countries'] = $this->openbay->ebay->getSetting('countries'); 1308 1309 if (is_array($setting['countries'])) { 1310 ksort($setting['countries']); 1311 } 1312 1313 $setting['returns'] = $this->openbay->ebay->getSetting('returns'); 1314 $setting['package_type'] = $this->openbay->ebay->getSetting('package_type'); 1315 $setting['shipping_types'] = $this->openbay->ebay->getSetting('shipping_types'); 1316 $setting['measurement_types'] = $this->openbay->ebay->getSetting('measurement_types'); 1317 $setting['measurement_types'] = $this->openbay->ebay->getSetting('measurement_types'); 1318 $setting['product_details'] = $this->openbay->ebay->getSetting('product_details'); 1319 $setting['listing_restrictions'] = $this->openbay->ebay->getSetting('listing_restrictions'); 1320 1321 if (!isset($setting['product_details']['product_identifier_unavailable_text'])) { 1322 $this->session->data['warning'] = $this->language->get('error_missing_settings'); 1323 $this->response->redirect($this->url->link('extension/openbay/ebay/syncronise&user_token=' . $this->session->data['user_token'], true)); 1324 } 1325 1326 if (empty($setting['dispatch_times']) || empty($setting['countries']) || empty($setting['returns'])){ 1327 $this->session->data['warning'] = $this->language->get('error_missing_settings'); 1328 $this->response->redirect($this->url->link('extension/openbay/ebay/syncronise&token=' . $this->session->data['user_token'], true)); 1329 } 1330 1331 $data['setting'] = $setting; 1332 1333 if ($this->openbay->addonLoad('openstock') && $product_info['has_option'] == 1) { 1334 $this->load->model('extension/module/openstock'); 1335 $data['addon']['openstock'] = true; 1336 $product_info['options'] = $this->model_setting_module_openstock->getVariants($this->request->get['product_id']); 1337 1338 $product_info['options_array'] = base64_encode(serialize($product_info['options'][0]['option_values'])); 1339 1340 $product_info['option_groups'] = $this->model_extension_openbay_ebay_product->getProductOptions($this->request->get['product_id']); 1341 1342 $option_group_array = array(); 1343 $option_group_relation_array = array(); 1344 1345 foreach($product_info['option_groups'] as $option_group) { 1346 $child_option = array(); 1347 1348 foreach($option_group['product_option_value'] as $group_node) { 1349 $child_option[$group_node['option_value_id']] = $group_node['name']; 1350 $option_group_relation_array[$group_node['product_option_value_id']] = $option_group['name']; 1351 } 1352 1353 $option_group_array[] = array('name' => $option_group['name'], 'child' => $child_option); 1354 } 1355 1356 $product_info['option_group_array'] = base64_encode(serialize($option_group_array)); 1357 $product_info['option_group_relation_array'] = base64_encode(serialize($option_group_relation_array)); 1358 } 1359 1360 // get the product tax rate from opencart 1361 if (isset($product_info['tax_class_id'])) { 1362 $product_info['defaults']['tax'] = $this->model_extension_openbay_ebay_product->getTaxRate($product_info['tax_class_id']); 1363 } else { 1364 $product_info['defaults']['tax'] = 0.00; 1365 } 1366 1367 //get the popular categories the user has used 1368 $product_info['popular_cats'] = $this->model_extension_openbay_ebay->getPopularCategories(); 1369 1370 //get shipping profiles 1371 $product_info['profiles_shipping'] = $this->model_extension_openbay_ebay_profile->getAll(0); 1372 //get default shipping profile 1373 $product_info['profiles_shipping_def'] = $this->model_extension_openbay_ebay_profile->getDefault(0); 1374 1375 //get returns profiles 1376 $product_info['profiles_returns'] = $this->model_extension_openbay_ebay_profile->getAll(1); 1377 //get default returns profile 1378 $product_info['profiles_returns_def'] = $this->model_extension_openbay_ebay_profile->getDefault(1); 1379 $data['data']['shipping_international_zones'] = $this->model_extension_openbay_ebay->getShippingLocations(); 1380 1381 //get theme profiles 1382 $product_info['profiles_theme'] = $this->model_extension_openbay_ebay_profile->getAll(2); 1383 //get default returns profile 1384 $product_info['profiles_theme_def'] = $this->model_extension_openbay_ebay_profile->getDefault(2); 1385 1386 //get generic profiles 1387 $product_info['profiles_generic'] = $this->model_extension_openbay_ebay_profile->getAll(3); 1388 //get default generic profile 1389 $product_info['profiles_generic_def'] = $this->model_extension_openbay_ebay_profile->getDefault(3); 1390 1391 //product attributes - this is just a direct pass through used with the template tag 1392 $product_info['attributes'] = base64_encode(json_encode($this->model_extension_openbay_ebay->getProductAttributes($this->request->get['product_id']))); 1393 1394 //post edit link 1395 $product_info['edit_link'] = $this->url->link('extension/openbay/ebay/edit', 'user_token=' . $this->session->data['user_token'] . '&product_id=' . $this->request->get['product_id'], true); 1396 1397 //images 1398 $product_images = $this->model_catalog_product->getProductImages($this->request->get['product_id']); 1399 $product_info['product_images'] = array(); 1400 1401 if (!empty($product_info['image'])) { 1402 $img_info = getimagesize(DIR_IMAGE . $product_info['image']); 1403 1404 $product_info['product_images'][] = array( 1405 'image' => $product_info['image'], 1406 'preview' => $this->model_tool_image->resize($product_info['image'], 100, 100), 1407 'full' => HTTPS_CATALOG . 'image/' . $product_info['image'], 1408 'width' => $img_info[0], 1409 'height' => $img_info[1], 1410 ); 1411 } 1412 1413 foreach ($product_images as $product_image) { 1414 if ($product_image['image'] && file_exists(DIR_IMAGE . $product_image['image'])) { 1415 $img_info = getimagesize(DIR_IMAGE . $product_image['image']); 1416 1417 $product_info['product_images'][] = array( 1418 'image' => $product_image['image'], 1419 'preview' => $this->model_tool_image->resize($product_image['image'], 100, 100), 1420 'full' => HTTPS_CATALOG . 'image/' . $product_image['image'], 1421 'width' => $img_info[0], 1422 'height' => $img_info[1], 1423 ); 1424 } 1425 } 1426 1427 $product_info['manufacturers'] = $this->model_catalog_manufacturer->getManufacturers(); 1428 $product_info['payments'] = $this->model_extension_openbay_ebay->getPaymentTypes(); 1429 $product_info['templates'] = $this->model_extension_openbay_ebay_template->getAll(); 1430 $product_info['store_cats'] = $this->model_extension_openbay_ebay->getSellerStoreCategories(); 1431 1432 $product_info['defaults']['cod_surcharge'] = 0; 1433 1434 foreach($product_info['payments'] as $payment) { 1435 if ($payment['ebay_name'] == 'COD') { 1436 $product_info['defaults']['cod_surcharge'] = 1; 1437 } 1438 } 1439 1440 $product_info['defaults']['ebay_payment_types'] = $this->config->get('ebay_payment_types'); 1441 $product_info['defaults']['paypal_address'] = $this->config->get('ebay_payment_paypal_address'); 1442 $product_info['defaults']['payment_instruction'] = $this->config->get('ebay_payment_instruction'); 1443 $product_info['defaults']['ebay_payment_immediate'] = $this->config->get('ebay_payment_immediate'); 1444 1445 $product_info['defaults']['gallery_height'] = '400'; 1446 $product_info['defaults']['gallery_width'] = '400'; 1447 $product_info['defaults']['thumb_height'] = '100'; 1448 $product_info['defaults']['thumb_width'] = '100'; 1449 1450 $product_info['defaults']['ebay_measurement'] = $this->config->get('ebay_measurement'); 1451 1452 $product_info['defaults']['listing_duration'] = $this->config->get('ebay_duration'); 1453 if ($product_info['defaults']['listing_duration'] == '') { 1454 $product_info['defaults']['listing_duration'] = 'Days_30'; 1455 } 1456 1457 if (isset($this->error['warning'])) { 1458 $data['error_warning'] = $this->error['warning']; 1459 } else { 1460 $data['error_warning'] = ''; 1461 } 1462 1463 if ($product_info['quantity'] < 1 && (!isset($product_info['has_option']) || $product_info['has_option'] == 0)) { 1464 $data['error_warning'] = $this->language->get('error_no_stock'); 1465 } 1466 1467 $data['no_image'] = $this->model_tool_image->resize('no_image.png', 100, 100); 1468 1469 $weight_parts = explode('.', $product_info['weight']); 1470 $product_info['weight_major'] = (int)$weight_parts[0]; 1471 $product_info['weight_minor'] = (int)substr($weight_parts[1], 0, 3); 1472 1473 $data['product'] = $product_info; 1474 1475 $data['header'] = $this->load->controller('common/header'); 1476 $data['column_left'] = $this->load->controller('common/column_left'); 1477 $data['footer'] = $this->load->controller('common/footer'); 1478 1479 $this->response->setOutput($this->load->view('extension/openbay/ebay_new', $data)); 1480 } else { 1481 $this->response->redirect($this->url->link('marketplace/openbay/items', 'user_token=' . $this->session->data['user_token'], true)); 1482 } 1483 } 1484 } 1485 1486 public function createBulk() { 1487 if ($this->checkConfig() == true) { 1488 if (!empty($this->request->post['selected'])) { 1489 $data = $this->load->language('extension/openbay/ebay_newbulk'); 1490 1491 $this->load->model('catalog/product'); 1492 $this->load->model('tool/image'); 1493 $this->load->model('catalog/manufacturer'); 1494 $this->load->model('extension/openbay/ebay'); 1495 $this->load->model('extension/openbay/ebay_profile'); 1496 1497 $data['breadcrumbs'] = array(); 1498 $data['breadcrumbs'][] = array( 1499 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true), 1500 'text' => $this->language->get('text_home'), 1501 ); 1502 $data['breadcrumbs'][] = array( 1503 'href' => $this->url->link('marketplace/openbay', 'user_token=' . $this->session->data['user_token'], true), 1504 'text' => $this->language->get('text_openbay'), 1505 ); 1506 $data['breadcrumbs'][] = array( 1507 'href' => $this->url->link('extension/openbay/ebay', 'user_token=' . $this->session->data['user_token'], true), 1508 'text' => $this->language->get('text_ebay'), 1509 ); 1510 1511 $data['breadcrumbs'][] = array( 1512 'href' => $this->url->link('extension/openbay/ebay/createBulk', 'user_token=' . $this->session->data['user_token'], true), 1513 'text' => $this->language->get('heading_title'), 1514 ); 1515 1516 $data['error_warning'] = array(); 1517 1518 $data['cancel'] = $this->url->link('marketplace/openbay/items', 'user_token=' . $this->session->data['user_token'], true); 1519 $data['image_directory'] = DIR_IMAGE; 1520 1521 $active_list = $this->model_extension_openbay_ebay->getLiveListingArray(); 1522 1523 $products = array(); 1524 1525 if ($this->openbay->addonLoad('openstock')) { 1526 $openstock = 1; 1527 } else { 1528 $openstock = 0; 1529 } 1530 1531 foreach ($this->request->post['selected'] as $product_id) { 1532 if (!array_key_exists($product_id, $active_list)) { 1533 1534 $prod = $this->model_catalog_product->getProduct($product_id); 1535 1536 if ($openstock == 1 && isset($prod['has_option']) && $prod['has_option'] == 1) { 1537 $data['error_warning']['os'] = $this->language->get('text_error_variants'); 1538 } else { 1539 if ($prod['quantity'] > 0) { 1540 if ($prod['image'] && file_exists(DIR_IMAGE . $prod['image'])) { 1541 $prod['image'] = $this->model_tool_image->resize($prod['image'], 80, 80); 1542 } else { 1543 $prod['image'] = $this->model_tool_image->resize('no_image.png', 80, 80); 1544 } 1545 1546 $products[] = $prod; 1547 } else { 1548 $data['error_warning']['stock'] = $this->language->get('text_error_stock'); 1549 } 1550 } 1551 } else { 1552 $data['error_warning']['exists'] = $this->language->get('text_exists'); 1553 } 1554 } 1555 1556 $data['count'] = count($products); 1557 $data['user_token'] = $this->session->data['user_token']; 1558 $data['listing_link'] = $this->config->get('ebay_itm_link'); 1559 1560 $plan = $this->model_extension_openbay_ebay->getMyPlan(); 1561 1562 if ($plan['plan']['listing_bulk'] == 1) { 1563 if ($data['count'] == 0) { 1564 $data['error_fail'][] = $this->language->get('text_error_no_product'); 1565 } else { 1566 if (($plan['plan']['listing_limit'] == 0) || (($plan['usage']['items'] + $data['count']) <= $plan['plan']['listing_limit'])) { 1567 if ($data['count'] > 5) { 1568 $data['error_warning']['count'] = sprintf($this->language->get('text_error_count'), $data['count']); 1569 } 1570 1571 //load the settings from eBay 1572 $setting = array(); 1573 1574 $setting['product_details'] = $this->openbay->ebay->getSetting('product_details'); 1575 1576 if (!isset($setting['product_details']['product_identifier_unavailable_text'])) { 1577 $this->session->data['warning'] = $this->language->get('error_missing_settings'); 1578 $this->response->redirect($this->url->link('extension/openbay/ebay/syncronise&token=' . $this->session->data['user_token'], true)); 1579 } 1580 1581 $setting['dispatch_times'] = $this->openbay->ebay->getSetting('dispatch_time_max'); 1582 if (is_array($setting['dispatch_times'])) { 1583 ksort($setting['dispatch_times']); 1584 } 1585 1586 $setting['countries'] = $this->openbay->ebay->getSetting('countries'); 1587 if (is_array($setting['countries'])) { 1588 ksort($setting['countries']); 1589 } 1590 1591 $setting['returns'] = $this->openbay->ebay->getSetting('returns'); 1592 1593 if (empty($setting['dispatch_times']) || empty($setting['countries']) || empty($setting['returns'])){ 1594 $this->session->data['warning'] = $this->language->get('error_missing_settings'); 1595 $this->response->redirect($this->url->link('extension/openbay/ebay/syncronise&token=' . $this->session->data['user_token'], true)); 1596 } 1597 1598 $data['setting'] = $setting; 1599 1600 //get generic profiles 1601 $product_info['profiles_generic'] = $this->model_extension_openbay_ebay_profile->getAll(3); 1602 //get default generic profile 1603 $product_info['profiles_generic_def'] = $this->model_extension_openbay_ebay_profile->getDefault(3); 1604 if ($product_info['profiles_generic_def'] === false) { 1605 $data['error_fail'][] = $this->language->get('text_error_generic_profile'); 1606 } 1607 1608 //get shipping profiles 1609 $product_info['profiles_shipping'] = $this->model_extension_openbay_ebay_profile->getAll(0); 1610 //get default shipping profile 1611 $product_info['profiles_shipping_def'] = $this->model_extension_openbay_ebay_profile->getDefault(0); 1612 //check it has a default profile 1613 if ($product_info['profiles_shipping_def'] === false) { 1614 $data['error_fail'][] = $this->language->get('text_error_ship_profile'); 1615 } 1616 1617 //get returns profiles 1618 $product_info['profiles_returns'] = $this->model_extension_openbay_ebay_profile->getAll(1); 1619 //get default returns profile 1620 $product_info['profiles_returns_def'] = $this->model_extension_openbay_ebay_profile->getDefault(1); 1621 //check it has a default profile 1622 if ($product_info['profiles_returns_def'] === false) { 1623 $data['error_fail'][] = $this->language->get('text_error_return_profile'); 1624 } 1625 1626 //get returns profiles 1627 $product_info['profiles_theme'] = $this->model_extension_openbay_ebay_profile->getAll(2); 1628 //get default returns profile 1629 $product_info['profiles_theme_def'] = $this->model_extension_openbay_ebay_profile->getDefault(2); 1630 //check it has a default profile 1631 if ($product_info['profiles_theme_def'] === false) { 1632 $data['error_fail'][] = $this->language->get('text_error_theme_profile'); 1633 } 1634 1635 // get the product tax rate 1636 if (isset($product_info['tax_class_id'])) { 1637 $product_info['defaults']['tax'] = $this->model_extension_openbay_ebay_product->getTaxRate($product_info['tax_class_id']); 1638 } else { 1639 $product_info['defaults']['tax'] = 0.00; 1640 } 1641 1642 $data['products'] = $products; 1643 1644 $product_info['manufacturers'] = $this->model_catalog_manufacturer->getManufacturers(); 1645 $product_info['payments'] = $this->model_extension_openbay_ebay->getPaymentTypes(); 1646 $product_info['store_cats'] = $this->model_extension_openbay_ebay->getSellerStoreCategories(); 1647 1648 $product_info['defaults']['ebay_template'] = $this->config->get('ebay_template'); 1649 1650 $product_info['defaults']['listing_duration'] = $this->config->get('ebay_duration'); 1651 if ($product_info['defaults']['listing_duration'] == '') { 1652 $product_info['defaults']['listing_duration'] = 'Days_30'; 1653 } 1654 1655 $data['default'] = $product_info; 1656 } else { 1657 $data['error_fail']['plan'] = sprintf($this->language->get('text_item_limit'), $this->url->link('extension/openbay/ebay/subscription', 'user_token=' . $this->session->data['user_token'], true)); 1658 } 1659 } 1660 } else { 1661 $data['error_fail']['plan'] = sprintf($this->language->get('text_bulk_plan_error'), $this->url->link('extension/openbay/ebay/subscription', 'user_token=' . $this->session->data['user_token'], true)); 1662 } 1663 1664 $this->document->setTitle($data['heading_title']); 1665 $this->document->addScript('view/javascript/openbay/js/faq.js'); 1666 $this->document->addScript('view/javascript/openbay/js/openbay.js'); 1667 1668 $data['header'] = $this->load->controller('common/header'); 1669 $data['column_left'] = $this->load->controller('common/column_left'); 1670 $data['footer'] = $this->load->controller('common/footer'); 1671 1672 $this->response->setOutput($this->load->view('extension/openbay/ebay_new_bulk', $data)); 1673 } else { 1674 $this->load->language('extension/openbay/ebay_newbulk'); 1675 $this->session->data['warning'] = $this->language->get('text_error_no_selection'); 1676 $this->response->redirect($this->url->link('marketplace/openbay/items&token=' . $this->session->data['user_token'])); 1677 } 1678 } 1679 } 1680 1681 public function verify() { 1682 $this->load->model('extension/openbay/openbay'); 1683 $this->load->model('extension/openbay/ebay'); 1684 $this->load->model('extension/openbay/ebay_template'); 1685 $this->load->model('catalog/product'); 1686 $this->load->model('catalog/filter'); 1687 1688 if ($this->request->server['REQUEST_METHOD'] == 'POST') { 1689 if ($this->checkConfig() == true) { 1690 $this->model_extension_openbay_ebay->logCategoryUsed($this->request->post['finalCat']); 1691 1692 $item_id = $this->openbay->ebay->getEbayItemId($this->request->post['product_id']); 1693 1694 if ($item_id == false) { 1695 $data = $this->request->post; 1696 1697 if ($data['template'] != 'None') { 1698 $template = $this->model_extension_openbay_ebay_template->get($data['template']); 1699 $data['template_html'] = (isset($template['html']) ? base64_encode($template['html']) : ''); 1700 } else { 1701 $data['template_html'] = ''; 1702 } 1703 1704 // set shipping data 1705 $data['national'] = $data['data']['national']; 1706 $data['international'] = $data['data']['international']; 1707 unset($data['data']); 1708 1709 if (!empty($data['img_tpl'])) { 1710 $tmp_gallery_array = array(); 1711 $tmp_thumbnail_array = array(); 1712 $this->load->model('tool/image'); 1713 1714 foreach ($data['img_tpl'] as $k => $v) { 1715 $tmp_gallery_array[$k] = $this->model_extension_openbay_openbay->storeImage($v, $data['gallery_width'], $data['gallery_height'], 'ebay'); 1716 $tmp_thumbnail_array[$k] = $this->model_extension_openbay_openbay->storeImage($v, $data['thumb_width'], $data['thumb_height'], 'ebay'); 1717 } 1718 1719 $data['img_tpl'] = $tmp_gallery_array; 1720 $data['img_tpl_thumb'] = $tmp_thumbnail_array; 1721 } 1722 1723 $query = $this->db->query("SELECT DISTINCT *, pd.name AS name, p.image, m.name AS manufacturer, (SELECT wcd.unit FROM " . DB_PREFIX . "weight_class_description wcd WHERE p.weight_class_id = wcd.weight_class_id AND wcd.language_id = '" . (int)$this->config->get('config_language_id') . "') AS weight_class, (SELECT lcd.unit FROM " . DB_PREFIX . "length_class_description lcd WHERE p.length_class_id = lcd.length_class_id AND lcd.language_id = '" . (int)$this->config->get('config_language_id') . "') AS length_class, p.sort_order FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) LEFT JOIN " . DB_PREFIX . "manufacturer m ON (p.manufacturer_id = m.manufacturer_id) WHERE p.product_id = '" . (int)$data['product_id'] . "' AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "'"); 1724 1725 $data['product_info'] = $query->row; 1726 1727 $data['product_info']['product_filters'] = array(); 1728 1729 $filters = $this->model_catalog_product->getProductFilters($this->request->post['product_id']); 1730 1731 foreach ($filters as $filter_id) { 1732 $filter_info = $this->model_catalog_filter->getFilter($filter_id); 1733 1734 if ($filter_info) { 1735 $data['product_info']['product_filters'][] = array( 1736 'filter_id' => $filter_info['filter_id'], 1737 'group' => $filter_info['group'], 1738 'name' => $filter_info['name'] 1739 ); 1740 } 1741 } 1742 1743 if (!empty($data['product_info']['sku'])){ 1744 $data['sku'] = $data['product_info']['sku']; 1745 } 1746 1747 $json = $this->model_extension_openbay_ebay->ebayVerifyAddItem($data, $this->request->get['options']); 1748 1749 $this->response->addHeader('Content-Type: application/json'); 1750 $this->response->setOutput(json_encode($json)); 1751 } else { 1752 $this->response->addHeader('Content-Type: application/json'); 1753 $this->response->setOutput(json_encode(array('error' => true, 'msg' => 'This item is already listed in your eBay account', 'item' => $item_id))); 1754 } 1755 } 1756 } else { 1757 $this->response->redirect($this->url->link('marketplace/openbay/items&token=' . $this->session->data['user_token'])); 1758 } 1759 } 1760 1761 public function verifyBulk() { 1762 $this->load->model('extension/openbay/openbay'); 1763 $this->load->model('extension/openbay/ebay_profile'); 1764 $this->load->model('extension/openbay/ebay'); 1765 $this->load->model('extension/openbay/ebay_template'); 1766 $this->load->model('catalog/product'); 1767 $this->load->model('tool/image'); 1768 $this->load->model('catalog/filter'); 1769 1770 if ($this->request->server['REQUEST_METHOD'] == 'POST') { 1771 if ($this->checkConfig() == true) { 1772 $post = $this->request->post; 1773 $data = array(); 1774 1775 //load all of the listing defaults and assign to correct variable names 1776 $profile_shipping = $this->model_extension_openbay_ebay_profile->get($post['shipping_profile']); 1777 $profile_return = $this->model_extension_openbay_ebay_profile->get($post['return_profile']); 1778 $profile_template = $this->model_extension_openbay_ebay_profile->get($post['theme_profile']); 1779 $profile_generic = $this->model_extension_openbay_ebay_profile->get($post['generic_profile']); 1780 1781 $payments = $this->model_extension_openbay_ebay->getPaymentTypes(); 1782 $payments_accepted = $this->config->get('ebay_payment_types'); 1783 $product_info = $this->model_catalog_product->getProduct($post['product_id']); 1784 1785 // set shipping data 1786 $data['national'] = $profile_shipping['data']['national']; 1787 $data['international'] = $profile_shipping['data']['international']; 1788 1789 $query = $this->db->query("SELECT DISTINCT *, pd.name AS name, p.image, m.name AS manufacturer, (SELECT wcd.unit FROM " . DB_PREFIX . "weight_class_description wcd WHERE p.weight_class_id = wcd.weight_class_id AND wcd.language_id = '" . (int)$this->config->get('config_language_id') . "') AS weight_class, (SELECT lcd.unit FROM " . DB_PREFIX . "length_class_description lcd WHERE p.length_class_id = lcd.length_class_id AND lcd.language_id = '" . (int)$this->config->get('config_language_id') . "') AS length_class, p.sort_order FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) LEFT JOIN " . DB_PREFIX . "manufacturer m ON (p.manufacturer_id = m.manufacturer_id) WHERE p.product_id = '" . (int)$post['product_id'] . "' AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "'"); 1790 1791 $data['product_info'] = $query->row; 1792 1793 $data['product_info']['product_filters'] = array(); 1794 1795 $filters = $this->model_catalog_product->getProductFilters($this->request->post['product_id']); 1796 1797 foreach ($filters as $filter_id) { 1798 $filter_info = $this->model_catalog_filter->getFilter($filter_id); 1799 1800 if ($filter_info) { 1801 $data['product_info']['product_filters'][] = array( 1802 'filter_id' => $filter_info['filter_id'], 1803 'group' => $filter_info['group'], 1804 'name' => $filter_info['name'] 1805 ); 1806 } 1807 } 1808 1809 1810 $data['description'] = $product_info['description']; 1811 $data['name'] = $post['title']; 1812 $data['sub_name'] = ''; 1813 $data['bestoffer'] = 0; 1814 $data['finalCat'] = $post['finalCat']; 1815 $data['price'][0] = $post['price']; 1816 $data['qty'][0] = (int)$post['qty']; 1817 $data['product_id'] = (int)$post['product_id']; 1818 1819 $data['feat'] = $post['feat']; 1820 $data['featother'] = $post['featother']; 1821 1822 if (!empty($product_info['sku'])){ 1823 $data['sku'] = $product_info['sku']; 1824 } 1825 1826 if (isset($post['identifier_ean']) && !empty($post['identifier_ean'])){ 1827 $data['identifier_ean'] = $post['identifier_ean']; 1828 } 1829 1830 if (isset($post['identifier_isbn']) && !empty($post['identifier_isbn'])){ 1831 $data['identifier_isbn'] = $post['identifier_isbn']; 1832 } 1833 1834 if (isset($post['identifier_upc']) && !empty($post['identifier_upc'])){ 1835 $data['identifier_upc'] = $post['identifier_upc']; 1836 } 1837 1838 $data['auction_duration'] = $post['duration']; 1839 $data['condition'] = (isset($post['condition']) && $post['condition'] != 0 ? $post['condition'] : ''); 1840 $data['auction_type'] = 'FixedPriceItem'; 1841 $data['catalog_epid'] = (isset($post['catalog_epid']) && $post['catalog_epid'] != 0 ? $post['catalog_epid'] : ''); 1842 $data['identifier_upc'] = (isset($post['identifier_upc']) && $post['identifier_upc'] != '' ? $post['identifier_upc'] : ''); 1843 $data['identifier_isbn'] = (isset($post['identifier_isbn']) && $post['identifier_isbn'] != '' ? $post['identifier_isbn'] : ''); 1844 $data['identifier_ean'] = (isset($post['identifier_ean']) && $post['identifier_ean'] != '' ? $post['identifier_ean'] : ''); 1845 1846 $data['ebay_payment_immediate'] = $this->config->get('ebay_payment_immediate'); 1847 $data['paypal_email'] = $this->config->get('ebay_payment_paypal_address'); 1848 $data['payment_instruction'] = $this->config->get('ebay_payment_instruction'); 1849 1850 if (isset($profile_return['data']['returns_accepted'])) { 1851 $data['returns_accepted'] = $profile_return['data']['returns_accepted']; 1852 } 1853 if (isset($profile_return['data']['returns_policy'])) { 1854 $data['return_policy'] = $profile_return['data']['returns_policy']; 1855 } 1856 if (isset($profile_return['data']['returns_option'])) { 1857 $data['returns_option'] = $profile_return['data']['returns_option']; 1858 } 1859 if (isset($profile_return['data']['returns_within'])) { 1860 $data['returns_within'] = $profile_return['data']['returns_within']; 1861 } 1862 if (isset($profile_return['data']['returns_shipping'])) { 1863 $data['returns_shipping'] = $profile_return['data']['returns_shipping']; 1864 } 1865 if (isset($profile_return['data']['returns_restocking_fee'])) { 1866 $data['returns_restocking_fee'] = $profile_return['data']['returns_restocking_fee']; 1867 } 1868 1869 $data['location'] = $profile_shipping['data']['location']; 1870 $data['postcode'] = $profile_shipping['data']['postcode']; 1871 $data['dispatch_time'] = $profile_shipping['data']['dispatch_time']; 1872 1873 if (isset($profile_shipping['data']['country'])) { 1874 $data['country'] = $profile_shipping['data']['country']; 1875 } 1876 1877 if (isset($profile_shipping['data']['eligible_for_pickup_dropoff'])) { 1878 $data['eligible_for_pickup_dropoff'] = $profile_shipping['data']['eligible_for_pickup_dropoff']; 1879 } 1880 1881 if (isset($profile_shipping['data']['eligible_for_pickup_instore'])) { 1882 $data['eligible_for_pickup_instore'] = $profile_shipping['data']['eligible_for_pickup_instore']; 1883 } 1884 1885 if (isset($profile_shipping['data']['global_shipping'])) { 1886 $data['global_shipping'] = $profile_shipping['data']['global_shipping']; 1887 } 1888 1889 if (isset($profile_shipping['data']['promotional_shipping_discount'])) { 1890 $data['promotional_shipping_discount'] = $profile_shipping['data']['promotional_shipping_discount']; 1891 } 1892 1893 if (isset($profile_shipping['data']['promotional_shipping_discount_international'])) { 1894 $data['promotional_shipping_discount_international'] = $profile_shipping['data']['promotional_shipping_discount_international']; 1895 } 1896 1897 $data['get_it_fast'] = (isset($profile_shipping['data']['get_it_fast']) ? $profile_shipping['data']['get_it_fast'] : 0); 1898 1899 if (isset($profile_template['data']['ebay_template_id'])) { 1900 $template = $this->model_extension_openbay_ebay_template->get($profile_template['data']['ebay_template_id']); 1901 $data['template_html'] = (isset($template['html']) ? base64_encode($template['html']) : ''); 1902 $data['template'] = $profile_template['data']['ebay_template_id']; 1903 } else { 1904 $data['template_html'] = ''; 1905 $data['template'] = ''; 1906 } 1907 1908 $data['gallery_plus'] = $profile_template['data']['ebay_gallery_plus']; 1909 $data['gallery_super'] = $profile_template['data']['ebay_supersize']; 1910 1911 $data['private_listing'] = $profile_generic['data']['private_listing']; 1912 1913 //product attributes - this is just a direct pass through used with the template tag 1914 $data['attributes'] = base64_encode(json_encode($this->model_extension_openbay_ebay->getProductAttributes($post['product_id']))); 1915 1916 $data['payments'] = array(); 1917 foreach($payments as $payment) { 1918 if ($payments_accepted[$payment['ebay_name']] == 1) { 1919 $data['payments'][$payment['ebay_name']] = 1; 1920 } 1921 } 1922 1923 $data['main_image'] = 0; 1924 $data['img'] = array(); 1925 1926 $product_images = $this->model_catalog_product->getProductImages($post['product_id']); 1927 1928 $product_info['product_images'] = array(); 1929 1930 if (!empty($product_info['image'])) { 1931 $data['img'][] = $product_info['image']; 1932 } 1933 1934 if (isset($profile_template['data']['ebay_img_ebay']) && $profile_template['data']['ebay_img_ebay'] == 1) { 1935 foreach ($product_images as $product_image) { 1936 if ($product_image['image'] && file_exists(DIR_IMAGE . $product_image['image'])) { 1937 $data['img'][] = $product_image['image']; 1938 } 1939 } 1940 } 1941 1942 if (isset($profile_template['data']['ebay_img_template']) && $profile_template['data']['ebay_img_template'] == 1) { 1943 $tmp_gallery_array = array(); 1944 $tmp_thumbnail_array = array(); 1945 1946 //if the user has not set the exclude default image, add it to the array for theme images. 1947 $key_offset = 0; 1948 if (!isset($profile_template['data']['default_img_exclude']) || $profile_template['data']['default_img_exclude'] != 1) { 1949 $tmp_gallery_array[0] = $this->model_extension_openbay_openbay->storeImage($product_info['image'], $profile_template['data']['ebay_gallery_width'], $profile_template['data']['ebay_gallery_height'], 'ebay'); 1950 $tmp_thumbnail_array[0] = $this->model_extension_openbay_openbay->storeImage($product_info['image'], $profile_template['data']['ebay_thumb_width'], $profile_template['data']['ebay_thumb_height'], 'ebay'); 1951 $key_offset = 1; 1952 } 1953 1954 //loop through the product images and add them. 1955 foreach ($product_images as $k => $v) { 1956 $tmp_gallery_array[$k+$key_offset] = $this->model_extension_openbay_openbay->storeImage($v['image'], $profile_template['data']['ebay_gallery_width'], $profile_template['data']['ebay_gallery_height'], 'ebay'); 1957 $tmp_thumbnail_array[$k+$key_offset] = $this->model_extension_openbay_openbay->storeImage($v['image'], $profile_template['data']['ebay_thumb_width'], $profile_template['data']['ebay_thumb_height'], 'ebay'); 1958 } 1959 1960 $data['img_tpl'] = $tmp_gallery_array; 1961 $data['img_tpl_thumb'] = $tmp_thumbnail_array; 1962 } 1963 1964 $weight_parts = explode('.', $product_info['weight']); 1965 1966 // package size and weights 1967 $data['package']['depth'] = $product_info['height']; 1968 $data['package']['irregular'] = 0; 1969 $data['package']['length'] = $product_info['length']; 1970 $data['package']['unit'] = $this->config->get('ebay_measurement'); 1971 $data['package']['weight_major'] = (int)$weight_parts[0]; 1972 $data['package']['weight_minor'] = (int)substr($weight_parts[1], 0, 3); 1973 $data['package']['width'] = $product_info['width']; 1974 1975 $package_types = $this->openbay->ebay->getSetting('package_type'); 1976 1977 foreach ($package_types as $package_type) { 1978 if ($package_type['default'] == 1) { 1979 $data['package']['package'] = $package_type['code']; 1980 } 1981 } 1982 1983 $data = array_merge($data, $profile_shipping['data']); 1984 1985 $verify_response = $this->model_extension_openbay_ebay->ebayVerifyAddItem($data, 'no'); 1986 1987 $json = array( 1988 'errors' => $verify_response['data']['Errors'], 1989 'fees' => $verify_response['data']['Fees'], 1990 'itemid' => (string)$verify_response['data']['ItemID'], 1991 'preview' => (string)$verify_response['data']['link'], 1992 'i' => $this->request->get['i'], 1993 'ack' => (string)$verify_response['data']['Ack'], 1994 ); 1995 1996 $this->response->addHeader('Content-Type: application/json'); 1997 $this->response->setOutput(json_encode($json)); 1998 } 1999 } else { 2000 $this->response->redirect($this->url->link('marketplace/openbay/items&token=' . $this->session->data['user_token'])); 2001 } 2002 } 2003 2004 public function listItem() { 2005 $this->load->model('extension/openbay/openbay'); 2006 $this->load->model('extension/openbay/ebay'); 2007 $this->load->model('extension/openbay/ebay_template'); 2008 $this->load->model('catalog/product'); 2009 $this->load->model('catalog/filter'); 2010 2011 if ($this->checkConfig() == true && $this->request->server['REQUEST_METHOD'] == 'POST') { 2012 $data = $this->request->post; 2013 2014 if ($data['template'] != 'None') { 2015 $template = $this->model_extension_openbay_ebay_template->get($data['template']); 2016 $data['template_html'] = (isset($template['html']) ? base64_encode($template['html']) : ''); 2017 } else { 2018 $data['template_html'] = ''; 2019 } 2020 2021 // set shipping data 2022 $data['national'] = $data['data']['national']; 2023 $data['international'] = $data['data']['international']; 2024 unset($data['data']); 2025 2026 if (!empty($data['img_tpl'])) { 2027 $tmp_gallery_array = array(); 2028 $tmp_thumbnail_array = array(); 2029 $this->load->model('tool/image'); 2030 2031 foreach ($data['img_tpl'] as $k => $v) { 2032 $tmp_gallery_array[$k] = $this->model_extension_openbay_openbay->storeImage($v, $data['gallery_width'], $data['gallery_height'], 'ebay'); 2033 $tmp_thumbnail_array[$k] = $this->model_extension_openbay_openbay->storeImage($v, $data['thumb_width'], $data['thumb_height'], 'ebay'); 2034 } 2035 2036 $data['img_tpl'] = $tmp_gallery_array; 2037 $data['img_tpl_thumb'] = $tmp_thumbnail_array; 2038 } 2039 2040 $query = $this->db->query("SELECT DISTINCT *, pd.name AS name, p.image, m.name AS manufacturer, (SELECT wcd.unit FROM " . DB_PREFIX . "weight_class_description wcd WHERE p.weight_class_id = wcd.weight_class_id AND wcd.language_id = '" . (int)$this->config->get('config_language_id') . "') AS weight_class, (SELECT lcd.unit FROM " . DB_PREFIX . "length_class_description lcd WHERE p.length_class_id = lcd.length_class_id AND lcd.language_id = '" . (int)$this->config->get('config_language_id') . "') AS length_class, p.sort_order FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) LEFT JOIN " . DB_PREFIX . "manufacturer m ON (p.manufacturer_id = m.manufacturer_id) WHERE p.product_id = '" . (int)$data['product_id'] . "' AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "'"); 2041 2042 $data['product_info'] = $query->row; 2043 2044 $data['product_info']['product_filters'] = array(); 2045 2046 $filters = $this->model_catalog_product->getProductFilters($this->request->post['product_id']); 2047 2048 foreach ($filters as $filter_id) { 2049 $filter_info = $this->model_catalog_filter->getFilter($filter_id); 2050 2051 if ($filter_info) { 2052 $data['product_info']['product_filters'][] = array( 2053 'filter_id' => $filter_info['filter_id'], 2054 'group' => $filter_info['group'], 2055 'name' => $filter_info['name'] 2056 ); 2057 } 2058 } 2059 2060 if (!empty($data['product_info']['sku'])){ 2061 $data['sku'] = $data['product_info']['sku']; 2062 } 2063 2064 $json = $this->model_extension_openbay_ebay->ebayAddItem($data, $this->request->get['options']); 2065 2066 $this->response->addHeader('Content-Type: application/json'); 2067 $this->response->setOutput(json_encode($json)); 2068 } else { 2069 $this->response->redirect($this->url->link('marketplace/openbay/items&token=' . $this->session->data['user_token'])); 2070 } 2071 } 2072 2073 public function listItemBulk() { 2074 $this->load->model('extension/openbay/openbay'); 2075 $this->load->model('extension/openbay/ebay_profile'); 2076 $this->load->model('extension/openbay/ebay'); 2077 $this->load->model('extension/openbay/ebay_template'); 2078 $this->load->model('catalog/product'); 2079 $this->load->model('tool/image'); 2080 $this->load->model('catalog/filter'); 2081 2082 if ($this->request->server['REQUEST_METHOD'] == 'POST') { 2083 if ($this->checkConfig() == true) { 2084 $post = $this->request->post; 2085 $data = array(); 2086 2087 //load all of the listing defaults and assign to correct variable names 2088 $profile_shipping = $this->model_extension_openbay_ebay_profile->get($post['shipping_profile']); 2089 $profile_return = $this->model_extension_openbay_ebay_profile->get($post['return_profile']); 2090 $profile_template = $this->model_extension_openbay_ebay_profile->get($post['theme_profile']); 2091 $profile_generic = $this->model_extension_openbay_ebay_profile->get($post['generic_profile']); 2092 $payments = $this->model_extension_openbay_ebay->getPaymentTypes(); 2093 $payments_accepted = $this->config->get('ebay_payment_types'); 2094 $product_info = $this->model_catalog_product->getProduct($post['product_id']); 2095 2096 // set shipping data 2097 $data['national'] = $profile_shipping['data']['national']; 2098 $data['international'] = $profile_shipping['data']['international']; 2099 2100 $query = $this->db->query("SELECT DISTINCT *, pd.name AS name, p.image, m.name AS manufacturer, (SELECT wcd.unit FROM " . DB_PREFIX . "weight_class_description wcd WHERE p.weight_class_id = wcd.weight_class_id AND wcd.language_id = '" . (int)$this->config->get('config_language_id') . "') AS weight_class, (SELECT lcd.unit FROM " . DB_PREFIX . "length_class_description lcd WHERE p.length_class_id = lcd.length_class_id AND lcd.language_id = '" . (int)$this->config->get('config_language_id') . "') AS length_class, p.sort_order FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) LEFT JOIN " . DB_PREFIX . "manufacturer m ON (p.manufacturer_id = m.manufacturer_id) WHERE p.product_id = '" . (int)$post['product_id'] . "' AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "'"); 2101 2102 $data['product_info'] = $query->row; 2103 2104 $data['product_info']['product_filters'] = array(); 2105 2106 $filters = $this->model_catalog_product->getProductFilters($this->request->post['product_id']); 2107 2108 foreach ($filters as $filter_id) { 2109 $filter_info = $this->model_catalog_filter->getFilter($filter_id); 2110 2111 if ($filter_info) { 2112 $data['product_info']['product_filters'][] = array( 2113 'filter_id' => $filter_info['filter_id'], 2114 'group' => $filter_info['group'], 2115 'name' => $filter_info['name'] 2116 ); 2117 } 2118 } 2119 2120 $data['description'] = $product_info['description']; 2121 $data['name'] = $post['title']; 2122 $data['sub_name'] = ''; 2123 $data['bestoffer'] = 0; 2124 $data['finalCat'] = $post['finalCat']; 2125 $data['price'][0] = $post['price']; 2126 $data['qty'][0] = $post['qty']; 2127 $data['product_id'] = $post['product_id']; 2128 2129 $data['feat'] = $post['feat']; 2130 $data['featother'] = $post['featother']; 2131 2132 if (!empty($product_info['sku'])){ 2133 $data['sku'] = $product_info['sku']; 2134 } 2135 2136 if (isset($post['identifier_ean']) && !empty($post['identifier_ean'])){ 2137 $data['identifier_ean'] = $post['identifier_ean']; 2138 } 2139 2140 if (isset($post['identifier_isbn']) && !empty($post['identifier_isbn'])){ 2141 $data['identifier_isbn'] = $post['identifier_isbn']; 2142 } 2143 2144 if (isset($post['identifier_upc']) && !empty($post['identifier_upc'])){ 2145 $data['identifier_upc'] = $post['identifier_upc']; 2146 } 2147 2148 $data['auction_duration'] = $post['duration']; 2149 $data['condition'] = (isset($post['condition']) && $post['condition'] != 0 ? $post['condition'] : ''); 2150 $data['auction_type'] = 'FixedPriceItem'; 2151 $data['catalog_epid'] = (isset($post['catalog_epid']) && $post['catalog_epid'] != 0 ? $post['catalog_epid'] : ''); 2152 $data['identifier_upc'] = (isset($post['identifier_upc']) && $post['identifier_upc'] != '' ? $post['identifier_upc'] : ''); 2153 $data['identifier_isbn'] = (isset($post['identifier_isbn']) && $post['identifier_isbn'] != '' ? $post['identifier_isbn'] : ''); 2154 $data['identifier_ean'] = (isset($post['identifier_ean']) && $post['identifier_ean'] != '' ? $post['identifier_ean'] : ''); 2155 2156 $data['ebay_payment_immediate'] = $this->config->get('ebay_payment_immediate'); 2157 $data['paypal_email'] = $this->config->get('ebay_payment_paypal_address'); 2158 $data['payment_instruction'] = $this->config->get('ebay_payment_instruction'); 2159 2160 if (isset($profile_return['data']['returns_accepted'])) { 2161 $data['returns_accepted'] = $profile_return['data']['returns_accepted']; 2162 } 2163 if (isset($profile_return['data']['returns_policy'])) { 2164 $data['return_policy'] = $profile_return['data']['returns_policy']; 2165 } 2166 if (isset($profile_return['data']['returns_option'])) { 2167 $data['returns_option'] = $profile_return['data']['returns_option']; 2168 } 2169 if (isset($profile_return['data']['returns_within'])) { 2170 $data['returns_within'] = $profile_return['data']['returns_within']; 2171 } 2172 if (isset($profile_return['data']['returns_shipping'])) { 2173 $data['returns_shipping'] = $profile_return['data']['returns_shipping']; 2174 } 2175 if (isset($profile_return['data']['returns_restocking_fee'])) { 2176 $data['returns_restocking_fee'] = $profile_return['data']['returns_restocking_fee']; 2177 } 2178 2179 $data['location'] = $profile_shipping['data']['location']; 2180 $data['postcode'] = $profile_shipping['data']['postcode']; 2181 $data['dispatch_time'] = $profile_shipping['data']['dispatch_time']; 2182 2183 if (isset($profile_shipping['data']['country'])) { 2184 $data['country'] = $profile_shipping['data']['country']; 2185 } 2186 2187 if (isset($profile_shipping['data']['eligible_for_pickup_dropoff'])) { 2188 $data['eligible_for_pickup_dropoff'] = $profile_shipping['data']['eligible_for_pickup_dropoff']; 2189 } 2190 2191 if (isset($profile_shipping['data']['eligible_for_pickup_instore'])) { 2192 $data['eligible_for_pickup_instore'] = $profile_shipping['data']['eligible_for_pickup_instore']; 2193 } 2194 2195 if (isset($profile_shipping['data']['global_shipping'])) { 2196 $data['global_shipping'] = $profile_shipping['data']['global_shipping']; 2197 } 2198 2199 if (isset($profile_shipping['data']['promotional_shipping_discount'])) { 2200 $data['promotional_shipping_discount'] = $profile_shipping['data']['promotional_shipping_discount']; 2201 } 2202 2203 if (isset($profile_shipping['data']['promotional_shipping_discount_international'])) { 2204 $data['promotional_shipping_discount_international'] = $profile_shipping['data']['promotional_shipping_discount_international']; 2205 } 2206 2207 $data['get_it_fast'] = (isset($profile_shipping['data']['get_it_fast']) ? $profile_shipping['data']['get_it_fast'] : 0); 2208 2209 if (isset($profile_template['data']['ebay_template_id'])) { 2210 $template = $this->model_extension_openbay_ebay_template->get($profile_template['data']['ebay_template_id']); 2211 $data['template_html'] = (isset($template['html']) ? base64_encode($template['html']) : ''); 2212 $data['template'] = $profile_template['data']['ebay_template_id']; 2213 } else { 2214 $data['template_html'] = ''; 2215 $data['template'] = ''; 2216 } 2217 2218 $data['gallery_plus'] = $profile_template['data']['ebay_gallery_plus']; 2219 $data['gallery_super'] = $profile_template['data']['ebay_supersize']; 2220 2221 $data['private_listing'] = $profile_generic['data']['private_listing']; 2222 2223 //product attributes - this is just a direct pass through used with the template tag 2224 $data['attributes'] = base64_encode(json_encode($this->model_extension_openbay_ebay->getProductAttributes($post['product_id']))); 2225 2226 $data['payments'] = array(); 2227 foreach($payments as $payment) { 2228 if ($payments_accepted[$payment['ebay_name']] == 1) { 2229 $data['payments'][$payment['ebay_name']] = 1; 2230 } 2231 } 2232 2233 $data['main_image'] = 0; 2234 $data['img'] = array(); 2235 2236 $product_images = $this->model_catalog_product->getProductImages($post['product_id']); 2237 2238 $product_info['product_images'] = array(); 2239 2240 if (!empty($product_info['image'])) { 2241 $data['img'][] = $product_info['image']; 2242 } 2243 2244 if (isset($profile_template['data']['ebay_img_ebay']) && $profile_template['data']['ebay_img_ebay'] == 1) { 2245 foreach ($product_images as $product_image) { 2246 if ($product_image['image'] && file_exists(DIR_IMAGE . $product_image['image'])) { 2247 $data['img'][] = $product_image['image']; 2248 } 2249 } 2250 } 2251 2252 if (isset($profile_template['data']['ebay_img_template']) && $profile_template['data']['ebay_img_template'] == 1) { 2253 $tmp_gallery_array = array(); 2254 $tmp_thumbnail_array = array(); 2255 2256 //if the user has not set the exclude default image, add it to the array for theme images. 2257 $key_offset = 0; 2258 if (!isset($profile_template['data']['default_img_exclude']) || $profile_template['data']['default_img_exclude'] != 1) { 2259 $tmp_gallery_array[0] = $this->model_extension_openbay_openbay->storeImage($product_info['image'], $profile_template['data']['ebay_gallery_width'], $profile_template['data']['ebay_gallery_height'], 'ebay'); 2260 $tmp_thumbnail_array[0] = $this->model_extension_openbay_openbay->storeImage($product_info['image'], $profile_template['data']['ebay_thumb_width'], $profile_template['data']['ebay_thumb_height'], 'ebay'); 2261 $key_offset = 1; 2262 } 2263 2264 //loop through the product images and add them. 2265 foreach ($product_images as $k => $v) { 2266 $tmp_gallery_array[$k+$key_offset] = $this->model_extension_openbay_openbay->storeImage($v['image'], $profile_template['data']['ebay_gallery_width'], $profile_template['data']['ebay_gallery_height'], 'ebay'); 2267 $tmp_thumbnail_array[$k+$key_offset] = $this->model_extension_openbay_openbay->storeImage($v['image'], $profile_template['data']['ebay_thumb_width'], $profile_template['data']['ebay_thumb_height'], 'ebay'); 2268 } 2269 2270 $data['img_tpl'] = $tmp_gallery_array; 2271 $data['img_tpl_thumb'] = $tmp_thumbnail_array; 2272 } 2273 2274 $weight_parts = explode('.', $product_info['weight']); 2275 2276 // package size and weights 2277 $data['package']['depth'] = $product_info['height']; 2278 $data['package']['irregular'] = 0; 2279 $data['package']['length'] = $product_info['length']; 2280 $data['package']['unit'] = $this->config->get('ebay_measurement'); 2281 $data['package']['weight_major'] = (int)$weight_parts[0]; 2282 $data['package']['weight_minor'] = (int)substr($weight_parts[1], 0, 3); 2283 $data['package']['width'] = $product_info['width']; 2284 2285 $package_types = $this->openbay->ebay->getSetting('package_type'); 2286 2287 foreach ($package_types as $package_type) { 2288 if ($package_type['default'] == 1) { 2289 $data['package']['package'] = $package_type['code']; 2290 } 2291 } 2292 2293 $data = array_merge($data, $profile_shipping['data']); 2294 2295 $verify_response = $this->model_extension_openbay_ebay->ebayAddItem($data, 'no'); 2296 2297 $json = array( 2298 'errors' => $verify_response['data']['Errors'], 2299 'fees' => $verify_response['data']['Fees'], 2300 'itemid' => (string)$verify_response['data']['ItemID'], 2301 'preview' => (string)$verify_response['data']['link'], 2302 'i' => $this->request->get['i'], 2303 'ack' => (string)$verify_response['data']['Ack'], 2304 ); 2305 2306 $this->response->addHeader('Content-Type: application/json'); 2307 $this->response->setOutput(json_encode($json)); 2308 } 2309 } else { 2310 $this->response->redirect($this->url->link('marketplace/openbay/items&token=' . $this->session->data['user_token'])); 2311 } 2312 } 2313 2314 public function repairLinks() { 2315 $this->load->model('extension/openbay/ebay_product'); 2316 2317 $this->model_extension_openbay_ebay_product->repairLinks(); 2318 2319 $json = array('msg' => 'Links repaired'); 2320 2321 $this->response->addHeader('Content-Type: application/json'); 2322 $this->response->setOutput(json_encode($json)); 2323 } 2324 2325 public function deleteAllLocks() { 2326 $this->openbay->ebay->log('deleteAllLocks() - Deleting all locks'); 2327 $this->db->query("DELETE FROM `" . DB_PREFIX . "ebay_order_lock`"); 2328 2329 $json = array('msg' => 'Locks deleted'); 2330 2331 $this->response->addHeader('Content-Type: application/json'); 2332 $this->response->setOutput(json_encode($json)); 2333 } 2334 2335 public function endItem() { 2336 $json = $this->openbay->ebay->endItem($this->request->get['item_id']); 2337 2338 $this->response->addHeader('Content-Type: application/json'); 2339 $this->response->setOutput(json_encode($json)); 2340 } 2341 2342 public function getPartsCompatibilityOptions() { 2343 $this->load->model('extension/openbay/ebay_product'); 2344 2345 $json = $this->model_extension_openbay_ebay_product->getPartsCompatibilityOptions($this->request->get['category_id']); 2346 2347 $this->response->addHeader('Content-Type: application/json'); 2348 $this->response->setOutput(json_encode($json)); 2349 } 2350 2351 public function getPartsCompatibilityValues() { 2352 $this->load->model('extension/openbay/ebay_product'); 2353 2354 $property_filter = array(); 2355 2356 if (isset($this->request->post['filters']) && !empty($this->request->post['filters'])) { 2357 $post_filters = $this->request->post['filters']; 2358 2359 foreach ($post_filters as $filter) { 2360 $property_filter[] = array( 2361 'property_filter_name' => $filter['property_filter_name'], 2362 'property_filter_value' => $filter['property_filter_value'], 2363 ); 2364 } 2365 } 2366 2367 $filters = array( 2368 'category_id' => $this->request->get['category_id'], 2369 'property_name' => $this->request->get['option_name'], 2370 'property_filter' => $property_filter, 2371 ); 2372 2373 $json = $this->model_extension_openbay_ebay_product->getPartsCompatibilityValues($filters); 2374 2375 $this->response->addHeader('Content-Type: application/json'); 2376 $this->response->setOutput(json_encode($json)); 2377 } 2378 2379 public function getItemRecommendations() { 2380 $this->load->language('extension/openbay/ebay_edit'); 2381 $this->load->model('extension/openbay/ebay_product'); 2382 2383 if (!isset($this->request->get['item_id']) || empty($this->request->get['item_id'])) { 2384 $json = array( 2385 'error' => true, 2386 'msg' => $this->language->get('error_no_item_id'), 2387 ); 2388 } else { 2389 $filters = array(); 2390 2391 $filters['item_id'] = $this->request->get['item_id']; 2392 2393 if (isset($this->request->get['recommendation_type'])) { 2394 $filters['recommendation_type'] = $this->request->get['recommendation_type']; 2395 } 2396 2397 $json = $this->model_extension_openbay_ebay_product->getItemRecommendations($filters); 2398 } 2399 2400 $this->response->addHeader('Content-Type: application/json'); 2401 $this->response->setOutput(json_encode($json)); 2402 } 2403 }