From d221554bce5ec8809ac058ef2f7ca8ae4ee0bf62 Mon Sep 17 00:00:00 2001 From: iyzoer Date: Wed, 7 Jun 2017 15:28:27 +0300 Subject: [PATCH] fix logs --- admin/controller/module/retailcrm.php | 13 ++++++++++++- admin/model/retailcrm/customer.php | 13 ++++++++++++- admin/model/retailcrm/history.php | 13 ++++++++++++- admin/model/retailcrm/order.php | 24 ++++++++++++++++++++++++ admin/model/retailcrm/references.php | 17 ++++++++++++++--- catalog/model/retailcrm/customer.php | 13 ++++++++++++- catalog/model/retailcrm/order.php | 15 +++++++++++++-- 7 files changed, 99 insertions(+), 9 deletions(-) diff --git a/admin/controller/module/retailcrm.php b/admin/controller/module/retailcrm.php index 3daf847..2576b1f 100644 --- a/admin/controller/module/retailcrm.php +++ b/admin/controller/module/retailcrm.php @@ -137,7 +137,7 @@ class ControllerModuleRetailcrm extends Controller $this->retailcrm = new RetailcrmProxy( $url, $key, - DIR_SYSTEM . 'logs/retailcrm.log' + $this->setLogs() ); $_data['delivery'] = $this->model_retailcrm_references @@ -338,4 +338,15 @@ class ControllerModuleRetailcrm extends Controller return false; } } + + private function setLogs() + { + if (version_compare(VERSION, '2.0', '>')) { + $logs = DIR_SYSTEM . 'storage/logs/ecomlogic.log'; + } else { + $logs = DIR_SYSTEM . 'logs/ecomlogic.log'; + } + + return $logs; + } } diff --git a/admin/model/retailcrm/customer.php b/admin/model/retailcrm/customer.php index a18c6c8..77c347a 100644 --- a/admin/model/retailcrm/customer.php +++ b/admin/model/retailcrm/customer.php @@ -16,7 +16,7 @@ class ModelRetailcrmCustomer extends Model { $this->retailcrmApi = new RetailcrmProxy( $settings['retailcrm_url'], $settings['retailcrm_apikey'], - DIR_SYSTEM . 'logs/retailcrm.log' + $this->serLogs() ); $customersToCrm = array(); @@ -48,4 +48,15 @@ class ModelRetailcrmCustomer extends Model { return $customerToCrm; } + + private function setLogs() + { + if (version_compare(VERSION, '2.0', '>')) { + $logs = DIR_SYSTEM . 'storage/logs/ecomlogic.log'; + } else { + $logs = DIR_SYSTEM . 'logs/ecomlogic.log'; + } + + return $logs; + } } diff --git a/admin/model/retailcrm/history.php b/admin/model/retailcrm/history.php index b984635..1ac2e42 100644 --- a/admin/model/retailcrm/history.php +++ b/admin/model/retailcrm/history.php @@ -41,7 +41,7 @@ class ModelRetailcrmHistory extends Model $crm = new RetailcrmProxy( $settings['retailcrm_url'], $settings['retailcrm_apikey'], - DIR_SYSTEM . 'logs/retailcrm.log' + $this->serLogs() ); $lastRun = !empty($history['retailcrm_history']) @@ -467,4 +467,15 @@ class ModelRetailcrmHistory extends Model return array('customers' => $customersIdsFix, 'orders' => $ordersIdsFix); } + + private function setLogs() + { + if (version_compare(VERSION, '2.0', '>')) { + $logs = DIR_SYSTEM . 'storage/logs/ecomlogic.log'; + } else { + $logs = DIR_SYSTEM . 'logs/ecomlogic.log'; + } + + return $logs; + } } diff --git a/admin/model/retailcrm/order.php b/admin/model/retailcrm/order.php index c9cd423..89843af 100644 --- a/admin/model/retailcrm/order.php +++ b/admin/model/retailcrm/order.php @@ -7,6 +7,19 @@ class ModelRetailcrmOrder extends Model { $this->load->model('setting/setting'); $this->settings = $this->model_setting_setting->getSetting('retailcrm'); + if(empty($orders)) + return false; + if(empty($settings['retailcrm_url']) || empty($settings['retailcrm_apikey'])) + return false; + + require_once DIR_SYSTEM . 'library/retailcrm/bootstrap.php'; + + $this->retailcrmApi = new RetailcrmProxy( + $settings['retailcrm_url'], + $settings['retailcrm_apikey'], + $this->serLogs() + ); + $ordersToCrm = array(); foreach($orders as $order) { @@ -113,4 +126,15 @@ class ModelRetailcrmOrder extends Model { return $order; } + + private function setLogs() + { + if (version_compare(VERSION, '2.0', '>')) { + $logs = DIR_SYSTEM . 'storage/logs/ecomlogic.log'; + } else { + $logs = DIR_SYSTEM . 'logs/ecomlogic.log'; + } + + return $logs; + } } diff --git a/admin/model/retailcrm/references.php b/admin/model/retailcrm/references.php index b5aef36..b1f3f00 100644 --- a/admin/model/retailcrm/references.php +++ b/admin/model/retailcrm/references.php @@ -91,7 +91,7 @@ class ModelRetailcrmReferences extends Model $this->retailcrm = new RetailcrmProxy( $settings['retailcrm_url'], $settings['retailcrm_apikey'], - DIR_SYSTEM . 'logs/retailcrm.log' + $this->setLogs() ); $response = $this->retailcrm->deliveryTypesList(); @@ -109,7 +109,7 @@ class ModelRetailcrmReferences extends Model $this->retailcrm = new RetailcrmProxy( $settings['retailcrm_url'], $settings['retailcrm_apikey'], - DIR_SYSTEM . 'logs/retailcrm.log' + $this->serLogs() ); $response = $this->retailcrm->statusesList(); @@ -127,7 +127,7 @@ class ModelRetailcrmReferences extends Model $this->retailcrm = new RetailcrmProxy( $settings['retailcrm_url'], $settings['retailcrm_apikey'], - DIR_SYSTEM . 'logs/retailcrm.log' + $this->setLogs() ); $response = $this->retailcrm->paymentTypesList(); @@ -135,4 +135,15 @@ class ModelRetailcrmReferences extends Model return ($response === false) ? array() : $response->paymentTypes; } } + + private function setLogs() + { + if (version_compare(VERSION, '2.0', '>')) { + $logs = DIR_SYSTEM . 'storage/logs/ecomlogic.log'; + } else { + $logs = DIR_SYSTEM . 'logs/ecomlogic.log'; + } + + return $logs; + } } diff --git a/catalog/model/retailcrm/customer.php b/catalog/model/retailcrm/customer.php index 093a109..fc2d061 100644 --- a/catalog/model/retailcrm/customer.php +++ b/catalog/model/retailcrm/customer.php @@ -15,7 +15,7 @@ class ModelRetailcrmCustomer extends Model { $this->retailcrmApi = new RetailcrmProxy( $settings['retailcrm_url'], $settings['retailcrm_apikey'], - DIR_SYSTEM . 'logs/retailcrm.log' + $this->setLogs() ); $customerToCrm = $this->process($customer); @@ -39,4 +39,15 @@ class ModelRetailcrmCustomer extends Model { return $customerToCrm; } + + private function setLogs() + { + if (version_compare(VERSION, '2.0', '>')) { + $logs = DIR_SYSTEM . 'storage/logs/ecomlogic.log'; + } else { + $logs = DIR_SYSTEM . 'logs/ecomlogic.log'; + } + + return $logs; + } } diff --git a/catalog/model/retailcrm/order.php b/catalog/model/retailcrm/order.php index f59f82d..f6ba894 100644 --- a/catalog/model/retailcrm/order.php +++ b/catalog/model/retailcrm/order.php @@ -17,7 +17,7 @@ class ModelRetailcrmOrder extends Model { $this->retailcrm = new RetailcrmProxy( $settings['retailcrm_url'], $settings['retailcrm_apikey'], - DIR_SYSTEM . 'logs/retailcrm.log' + $this->setLogs() ); $order = array(); @@ -157,7 +157,7 @@ class ModelRetailcrmOrder extends Model { $this->retailcrm = new RetailcrmProxy( $settings['retailcrm_url'], $settings['retailcrm_apikey'], - DIR_SYSTEM . 'logs/retailcrm.log' + $this->setLogs() ); $order = array(); @@ -257,4 +257,15 @@ class ModelRetailcrmOrder extends Model { $this->retailcrm->ordersEdit($order); } } + + private function setLogs() + { + if (version_compare(VERSION, '2.0', '>')) { + $logs = DIR_SYSTEM . 'storage/logs/ecomlogic.log'; + } else { + $logs = DIR_SYSTEM . 'logs/ecomlogic.log'; + } + + return $logs; + } }